Computer Knowledge
Database and SQL
3,929 Questions
Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.
SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions
Database and SQL Questions
-
Insert into doctor values('Sam','Twain')
-
Insert ('Sam','Twain') into doctors
-
Insert values('Sam','Twain') into doctors
-
Insert doctor values('Sam','Twain')
A
Correct answer
Explanation
The Insert statement in SQL has the following syntax Insert into tablename values(value1,value2,value3....) For example, in a table named Patients which has the following structure.
|||
|---|---|
|Column |Datatype|
|Patcd|number|
|Patname|varchar2(10) |
The statement to insert a new record will be Insert into patients values(1,'Sanjay') Make sure that all the VARCHAR and DATE columns are enclosed in a pair of single quotes.
-
Select
-
Display
-
Get
-
Describe
A
Correct answer
Explanation
The Select statement is used to extract or display data of a table. Using a Select statement, a table can be printed either fully or partially. We can also add a condition so that only those records that fit the criteria can be displayed. Example: To print all the columns of a table the command will be Select * from tablename where * denotes that all the columns have to be printed. In case we want to print only selected columns we can replace * with the column names as select rollno, name from students. To add a condition, the where clause can be added to the select statement Select rollno, name from students where rollno=1.
-
Insert
-
Delete
-
Alter
-
Update
C
Correct answer
Explanation
The alter keyword is used to alter (modify) the structure of the table. It is different from the other options because it is the only option which belongs to the DDL (Data Definition Language) part of the SQL. DDL statements are those statements that are used to define or modify the structure of the table. SQL statements like Create and Alter are DDL statements because they work on the structure of the table rather than the data.
-
Remove
-
Truncate
-
Delete
-
Drop
C
Correct answer
Explanation
The Delete statement is used to delete all or selected rows from a table. It is a part of DML or Data Manipulation Language part of SQL. Its syntax is delete from tablename where conditionexample: Delete from students where marks>50. If the 'Where clause' is omitted from the above statement, it will delete all the records from a table.
-
Distinct
-
Primary key
-
Unique
-
Different
A
Correct answer
Explanation
There are situations where the values in a column are repeated. For example, the city column of a table can have many records of Mumbai, Delhi etc. To display the repeated values just once we can put the distinct clause with the where clause. For example, the statement select distinct(city) from list will display the name of a city only once. If the name of a city is present in the table more than once it will be shown just once.
-
Relational database model does not have deletion anomalies.
-
Network database does not have deletion anomalies.
-
Network database does not have updation anomalies.
-
None of the above.
-
Both (2) and (3).
D
Correct answer
Explanation
All are the correct statements about the relational database models.
-
The table should be in 2 NF.
-
The non-prime attributes must be dependent on primary key.
-
There must be transitive functional dependency to be in 3NF.
-
All of the above.
-
Both (1) and (2).
E
Correct answer
Explanation
These are correct statements.
-
Amount of data duplication is not possible.
-
Data integrity is achieved.
-
Less amount of overhead possible.
-
All of the above.
-
Both (1) and (2).
D
Correct answer
Explanation
All are the advantages of removal of transitive dependency form the database.
-
First normal form provides the unordered set of data.
-
Second normal from considers all the non primary columns in the table should depend on the primary key.
-
Third normal form does not have any transitive dependency.
-
There are no anomalies possible in data normalization.
-
None of the above
E
Correct answer
Explanation
All are the correct statements.
-
It creates a set of separate table for each set of data.
-
It identify each set of related data with a foreign key.
-
It eliminates the repeating groups of data.
-
Both (2) and (3).
-
None of the above
B
Correct answer
Explanation
It uses a primary key for identification of each set of related data in the database.
-
getColumnCount()
-
getColCount()
-
getCols()
-
getColsCount()
-
getColumns()
A
Correct answer
Explanation
This is the correct answer.
-
executeQuery(s);
-
executeUpdate(s);
-
executeStatement(s);
-
executeString(s);
-
execute(s)
A
Correct answer
Explanation
This is the correct answer.
-
Database triggers
-
Package
-
Cursors
-
None of these
C
Correct answer
Explanation
Cursors provide a way for your program to select multiple rows of data from the database and then process each row individually in PL/SQL
-
View
-
Table
-
Segment
-
Extent
-
Abort
A
Correct answer
Explanation
This logical storage structure can also be considered a stored query.
-
select count()from student;
-
select count(*)from student;
-
select No_Rows_Tablefrom student;
-
select max(age)from student;
-
select min(salary)from student;
B
Correct answer
Explanation
This is the correct query and returns the total number of rows in the table student.