SQL Data Definition Language (DDL) Exercises with Solutions
SQL Data Definition Language (DDL) exercises with solutions [15 exercises with solution]
1. Create a Table
Write a SQL query to create a table with specific columns and constraints.
2. Add a New Column
Write a SQL query to add a new column to an existing table.
3. Modify a Column's Data Type
Write a SQL query to change the data type of an existing column in a table.
4. Drop a Column
Write a SQL query to remove a column from an existing table.
5. Add a Unique Constraint
Write a SQL query to add a unique constraint to a column in an existing table.
6. Add a Foreign Key
Write a SQL query to create a foreign key relationship between two tables.
7. Drop a Table
Write a SQL query to permanently delete a table and all its data.
8. Truncate a Table
Write a SQL query to remove all rows from a table while retaining its structure.
9. Create an Index
Write a SQL query to create an index on a column to improve query performance.
10. Drop an Index
Write a SQL query to remove an index from a table.
11. Rename a Table
Write a SQL query to rename an existing table.
12. Add a Default Value
Write a SQL query to assign a default value to a column in an existing table.
13. Remove a Constraint
Write a SQL query to remove a constraint from an existing table.
14. Create a Schema
Write a SQL query to create a new schema in the database.
15. Move a Table to a Schema
Write a SQL query to move a table from one schema to another.
More to Come !
Practice Online
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics