SQL Programming Advanced Quiz 5
Select your answers and check your results. Use Reset to start again.
Search
Practice Pronunciation (Merriam-Webster)
Navigation
Python Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Python Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Python Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
SQL Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
SQL Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
SQL Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
JavaScript Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
JavaScript Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
JavaScript Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C# Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C# Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C# Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Java Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Java Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Java Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C Programming Beginner Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C Programming Intermediate Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
C Programming Advanced Quizzes
Quiz 1,
Quiz 2,
Quiz 3,
Quiz 4,
Quiz 5
Advanced Quiz 5
1. Write a SQL query to add a new column "age" to table "students".
ALTER TABLE students ADD age INT;
ADD COLUMN age TO students;
ALTER students ADD age INT;
2. Write a SQL query to remove all rows from a table but keep its structure.
TRUNCATE TABLE table;
DROP TABLE table;
DELETE TABLE table;
3. Write a SQL query to create an index on column "email" in table "users".
CREATE INDEX idx_email ON users(email);
ADD INDEX email TO users;
INDEX idx_email ON users(email);
4. Write a SQL query to remove a column "phone" from table "contacts".
ALTER TABLE contacts DROP COLUMN phone;
REMOVE COLUMN phone FROM contacts;
DELETE phone FROM contacts;
5. Write a SQL query to find duplicate records in a table.
SELECT col1, col2, COUNT(*) FROM table GROUP BY col1, col2 HAVING COUNT(*) > 1;
SELECT * FROM table WHERE duplicate = TRUE;
SELECT DISTINCT * FROM table;
6. Write a SQL query to select the total sales for each month.
SELECT EXTRACT(MONTH FROM sale_date) AS month, SUM(amount) FROM Sales GROUP BY month;
SELECT MONTH(sale_date), SUM(amount) FROM Sales;
SELECT sale_date, SUM(amount) FROM Sales GROUP BY sale_date;
7. Write a SQL query to find the minimum and maximum salary in "employees".
SELECT MIN(salary), MAX(salary) FROM employees;
SELECT salary FROM employees WHERE salary = MIN OR MAX;
SELECT salary FROM employees ORDER BY salary LIMIT 1;
8. Write a SQL query to change the data type of column "price" to DECIMAL(10,2) in "products".
ALTER TABLE products ALTER COLUMN price TYPE DECIMAL(10,2);
CHANGE COLUMN price TO DECIMAL(10,2);
MODIFY COLUMN price DECIMAL(10,2);
9. Write a SQL query to rename table "orders" to "customer_orders".
ALTER TABLE orders RENAME TO customer_orders;
RENAME TABLE orders AS customer_orders;
UPDATE TABLE orders SET name = 'customer_orders';
10. Write a SQL query to add a NOT NULL constraint to column "username" in table "accounts".
ALTER TABLE accounts ALTER COLUMN username SET NOT NULL;
ALTER TABLE accounts ADD NOT NULL TO username;
MODIFY accounts SET username NOT NULL;
Previous
Check Quiz
Reset
Next
Other
Timer
00:00
Start
Stop
Reset
Vocabulary Quiz
Score: 0
Reset Score
Submit Answer
Next Word
Spin the Wheel
SPIN
Promo's
Explore More
C# Documentation
C# Tutorials