NEW
Font size
WorksheetsSQL and Database Quiz
Total questions: 15
Worksheet time: 8mins
Which command is used to rollback the last transaction?
COMMIT;
ROLLBACK;
SAVEPOINT;
UNDO;
How to add a primary key constraint to an existing table?
ALTER TABLE Employee ADD PRIMARY KEY (EMPNO);
ALTER Employee ADD PRIMARY KEY (EMPNO);
ADD PRIMARY KEY TO Employee (EMPNO);
ALTER Employee TABLE ADD PRIMARY KEY (EMPNO);
How to add a NOT NULL constraint to a column?
ALTER TABLE Employee ADD CONSTRAINT NOT NULL (EMPNO);
ALTER TABLE Employee MODIFY EMPNO NOT NULL;
ALTER TABLE Employee ADD NOT NULL (EMPNO);
ALTER Employee MODIFY COLUMN EMPNO NOT NULL;
Which command is used to insert a new record into a table?
INSERT INTO Employee VALUES (101, 'John', 'Manager', 1001, 5000, NULL);
ADD INTO Employee VALUES (101, 'John', 'Manager', 1001, 5000, NULL);
INSERT INTO Employee SET (101, 'John', 'Manager', 1001, 5000, NULL);
INSERT INTO Employee SET VALUES (101, 'John', 'Manager', 1001, 5000, NULL);
How to add a new column to an existing table?
ALTER TABLE Employee ADD COLUMN commission DECIMAL(10,2);
ALTER Employee ADD COLUMN commission DECIMAL(10,2);
ALTER TABLE Employee MODIFY commission DECIMAL(10,2);
ALTER Employee TABLE ADD COLUMN commission DECIMAL(10,2);
How to update the details of a column in a table?
UPDATE Employee SET JOB = 'Developer' WHERE EMPNO = 101;
MODIFY Employee SET JOB = 'Developer' WHERE EMPNO = 101;
CHANGE Employee SET JOB = 'Developer' WHERE EMPNO = 101;
ALTER Employee SET JOB = 'Developer' WHERE EMPNO = 101;
How to rename a column in a table?
ALTER TABLE Employee RENAME COLUMN commission TO bonus;
CHANGE Employee RENAME COLUMN commission TO bonus;
MODIFY Employee RENAME COLUMN commission TO bonus;
RENAME Employee RENAME COLUMN commission TO bonus;
Which command is used to delete a record from a table?
DELETE FROM Employee WHERE EMPNO = 105;
REMOVE FROM Employee WHERE EMPNO = 105;
DROP FROM Employee WHERE EMPNO = 105;
ERASE FROM Employee WHERE EMPNO = 105;
How to count the number of employee names in a table?
SELECT COUNT(E_name) FROM Employee;
SELECT TOTAL(E_name) FROM Employee;
SELECT SUM(E_name) FROM Employee;
SELECT NUMBER(E_name) FROM Employee;
How to find the maximum age in a table?
SELECT MAX(Age) FROM Employee;
SELECT HIGHEST(Age) FROM Employee;
SELECT BIGGEST(Age) FROM Employee;
SELECT LARGEST(Age) FROM Employee;
How to sort salaries of employees in ascending order?
SELECT Salary FROM Employee ORDER BY Salary ASC;
SELECT Salary FROM Employee ORDER BY Salary;
SELECT Salary FROM Employee SORT BY Salary;
SELECT Salary FROM Employee ORDER Salary ASC;
How to group salaries of employees?
SELECT Salary FROM Employee GROUP BY Salary;
SELECT Salary FROM Employee ORDER BY Salary;
SELECT Salary FROM Employee SORT BY Salary;
SELECT Salary FROM Employee GROUP Salary;
How to open a cursor in PL/SQL?
OPEN cursor_name;
ACTIVATE cursor_name;
BEGIN cursor_name;
START cursor_name;
How to close a cursor in PL/SQL?
CLOSE cursor_name;
DEACTIVATE cursor_name;
END cursor_name;
STOP cursor_name;
What does CRUD stand for in database operations?
Create, Read, Update, Delete
Create, Retrieve, Update, Delete
Create, Remove, Update, Delete
Create, Reorganize, Update, Delete
