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

Multiple choice
  1. Insert into doctor values('Sam','Twain')

  2. Insert ('Sam','Twain') into doctors

  3. Insert values('Sam','Twain') into doctors

  4. Insert doctor values('Sam','Twain')

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Select

  2. Display

  3. Get

  4. Describe

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Insert

  2. Delete

  3. Alter

  4. Update

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Remove

  2. Truncate

  3. Delete

  4. Drop

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Distinct

  2. Primary key

  3. Unique

  4. Different

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. The table should be in 2 NF.

  2. The non-prime attributes must be dependent on primary key.

  3. There must be transitive functional dependency to be in 3NF.

  4. All of the above.

  5. Both (1) and (2).

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

These are correct statements.

Multiple choice
  1. First normal form provides the unordered set of data.

  2. Second normal from considers all the non primary columns in the table should depend on the primary key.

  3. Third normal form does not have any transitive dependency.

  4. There are no anomalies possible in data normalization.

  5. None of the above

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

All are the correct statements.

Multiple choice
  1. It creates a set of separate table for each set of data.

  2. It identify each set of related data with a foreign key.

  3. It eliminates the repeating groups of data.

  4. Both (2) and (3).

  5. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

It uses a primary key for identification of each set of related data in the database.