Computer Knowledge

Database and SQL

4,213 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. PRIMARY KEY Constraint

  2. UNIQUE KEY Constraint

  3. CHECK Constraint

  4. FOREIGN KEY Constraint

  5. NOT NULL Constraint

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

All the Constraints can be applied when you have only one table. But to apply FOREIGN KEY Constraint, two tables are required. Option 4 is the correct choice.

FYI - Rare scenario is A Foreign Key can be applied on single table on its primary key, which is very rare in reality.

Multiple choice
  1. 1, 2, 4 are correct

  2. 1, 3 and 5 are correct

  3. 3, 4 and 5 are correct

  4. 2, 3 and 4 are correct

  5. All are correct

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation
  1. No, A Table can have only one primary key.
    1. No, It is not mandatory. It is one of the ways to define a PRIMARY KEY.
    2. Yes, PRIMARY KEY can be added after creating the Table using ALTER .
    3. Yes, using ALTER statement.
    4. Yes, can use NOT NULL constraint.
Multiple choice
  1. CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL CHECK (AGE >= 18), ADDRESS CHAR (25) , MARKS INT, PRIMARY KEY (STUDENT_ID));

  2. CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL , ADDRESS CHAR (25) , MARKS INT, PRIMARY KEY (STUDENT_ID)); ALTER TABLE STUDENTS MODIFY AGE INT NOT NULL CHECK (AGE >= 18 );

  3. CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL , ADDRESS CHAR (25) , MARKS INT, PRIMARY KEY (STUDENT_ID));ALTER TABLE STUDENTS ADD CONSTRAINT myCheckConstraint CHECK(AGE >= 18);

  4. Check constraint has introduced only from ORACLE 10g onwards.

  5. All Option 1, Option 2 and Option 3 are correct.

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

Yes, All three options are correct.