Swapna Kumar Panda
Swapna Kumar Panda

@swapnakpanda

19 Tweets 3 reads Dec 20, 2022
Practicing is the best way to master SQL. Here are 75+ practice questions:
Questions will be from:
➊ Table - DDL
➋ Constraints
➀ Primary Key
➁ Unique
➂ Not Null
➃ Default
➄ Check
➅ Foreign Key
➌ Insert, Update, Delete Records
➍ Select Records
➊ Table - DDL
➀ Create a table with a few fields by specifying their data types.
➁ Add a field to an existing table.
➂ Modify a field's data type of a table.
➃ Rename a field's name.
➄ Remove a field from a table.
➅ Rename a table's name.
➆ Drop a table.
➋.➀ Primary Key Constraint
➤ Create a Table with
➀ a single field as the primary key
➁ 2 or, more fields as the primary key
...
➤ Add a primary key to an existing table
➂ for a single field
➃ for 2 or, more fields
...
➋.➁ Unique Constraint
➤ Create a Table with
➀ a single field unique
➁ 2 or, more fields combining unique
➂ multiple unique fields
...
➤ Add a unique constraint to an existing table
➃ for a single field
➄ for 2 or, more fields combining
...
➅ Drop a unique constraint
➋.➂ Not Null Constraint
➤ Create a Table with
➀ one NOT NULL field
➁ multiple NOT NULL fields
...
➂ Add NOT NULL constraint to an existing field
➃ Remove NOT NULL constraint from an existing field
➋.➃ Default Value Constraint
➤ Create a Table with DEFAULT value(s)
➀ for one field
➁ multiple fields
...
➂ Add a DEFAULT value constraint to an existing field
➃ Remove DEFAULT value constraint from an existing field
➋.➄ Check Constraint
➤ Create a Table with CHECK constraint for
➀ a single field
➁ 2 or, more fields
➂ multiple separated fields
...
➤ Add a CHECK constraint to an existing table
➃ for a single field
➄ for 2 or, more fields combining
...
➅ Drop a CHECK constraint
➋.➅ Foreign Key
➤ Create a Table with
➀ a single foreign key field
➁ 2 or, more fields combining foreign key
➂ multiple foreign key fields
...
➤ Add a foreign key constraint to a table
➃ for a single field
➄ for 2 or, more fields combining
...
➅ Drop a foreign key
➌ Insert, Update, Delete Records
➀ Insert a row into a table.
➁ Insert a row into a table by providing data for a few fields.
➂ Insert multiple rows at a time into a table.
➃ Insert into a table by selecting the needed data from another table.
➄ Update a specific field's data in a table.
➅ Update a field's data for multiple rows at a time.
➆ Delete a row from a table.
➇ Delete multiple rows from a table.
➍ Select Records
➀ Fetch all rows from a table.
➁ Fetch only specific fields' data from a table.
➂ Fetch only those rows that match a condition.
➃ Apply multiple conditions.
➄ Check if a field's data is NULL.
➅ Check if a field's data is not NULL.
➆ Check if a field's data starts with "Sea"
➇ Check if a field's data ends with "ida"
➈ Check if a field's data contains "angh"
➉ Check if a field's data has "r" at 2nd position
➀➀ Check if a field's data starts with "S" and has at least 5 characters.
➀➁ Check if a field's data starts with "M" and ends with "r".
➀➂ Check if a field's data starts with "J" or "N".
➀➃ Check if a field's data doesn't contain "i" or "u" at the 2nd position.
➀➄ Check if a field's data ends with any character from "h" to "r".
➀➅ Check if a field's data is either 2, 8, 20, 25, or 50.
➀➆ Check if a field's data is neither 3, 6, nor 9.
➀➇ Check if a field's data is in the range of 5 to 25.
➀➈ Check if a field's data is not in the range of 1 to 10.
20. Fetch only distinct data contained in a field
➁➀ Find the minimum value of a field.
➁➁ Find the maximum value of a field.
➁➂ Find the average value of a field.
➁➃ Find the sum of all the values contained in a field.
➁➄ Fetch rows in ascending order for a field.
➁➅ Fetch rows in descending order for a field.
➁➆ Find the number of rows fetched.
➁➇ Find the count of distinct data in a field.
➁➈ Fetch only the first 20 rows.
30. Fetch rows from 11 to 20.
🏁 Final Words
⬘ Practice all these and try to come up with your own questions by customizing all of them. Practice more on:
➤ Hackerank
➤ SQLZOO
➤ Schemaverse
➤ SQLPad
⬙ It's an ongoing series. I will share more practice questions in the coming days.
Hey 👋
I am a Tech Writer, Educator, and Mentor from India 🇮🇳, here sharing
✰ Tutorials
✰ Career Tips
✰ Practice Questions
✰ Roadmaps
on
➠ Web Development
➠ DSA
➠ Databases
Check this tweet for SQL practice questions:

Loading suggestions...