Exit Chapter 10 ยท ๐Ÿฌ Introduction to SQL โ€” Quiz

Playing as a guest? to earn XP and track your progress.

Question 1 of 54 0 correct so far

๐Ÿฌ Introduction to SQL Quiz

Q1.

SQL stands for:

Explanation

SQL is the standard language for working with relational databases.

Q2.

SQL is used to work with:

Explanation

SQL creates, changes and queries data stored in tables.

Q3.

MySQL is a:

Explanation

MySQL is a relational database management system that uses SQL.

Q4.

Are SQL keywords case sensitive?

Explanation

SQL keywords are not case sensitive, though capitals are used for readability.

Q5.

Which symbol ends an SQL statement in MySQL?

Explanation

Each SQL statement ends with a semicolon.

Q6.

DDL stands for:

Explanation

DDL commands define or change the structure of database objects.

Q7.

DML stands for:

Explanation

DML commands work on the data stored in tables.

Q8.

DQL stands for:

Explanation

DQL commands read (query) data โ€” mainly SELECT.

Q9.

Which of these is a DDL command?

Explanation

CREATE, ALTER and DROP are DDL commands.

Q10.

Which of these is a DML command?

Explanation

INSERT, UPDATE and DELETE are DML commands.

Q11.

SELECT belongs to which category?

Explanation

SELECT only reads data, so it is the DQL command.

Q12.

Which group contains ONLY DDL commands?

Explanation

DDL commands change the structure, not the data.

Q13.

Which group contains ONLY DML commands?

Explanation

DML = Insert, Update, Delete (IUD).

Q14.

ALTER TABLE is which type of command?

Explanation

ALTER changes the structure of a table.

Q15.

Which data type stores FIXED-length text?

Explanation

CHAR(n) always uses n characters, padding with spaces.

Q16.

Which data type stores VARIABLE-length text?

Explanation

VARCHAR(n) uses only as much space as the text needs, up to n.

Q17.

'Riya' is stored in CHAR(10). How many characters of space does it use?

Explanation

CHAR always uses the full fixed length.

Q18.

'Riya' is stored in VARCHAR(10). How much space does the text use?

Explanation

VARCHAR stores only the actual characters.

Q19.

Which data type is best for a Gender column holding 'M' or 'F'?

Explanation

The value always has exactly 1 character.

Q20.

Which data type is best for storing whole numbers like RollNo?

Explanation

INT stores integers.

Q21.

DECIMAL(8, 2) can store numbers with:

Explanation

In DECIMAL(p, s), p is the total digits and s is the digits after the point.

Q22.

In which format is a DATE value written in MySQL?

Explanation

Example: '2009-05-21'.

Q23.

Which values must be written inside single quotes in SQL?

Explanation

Text and dates go in quotes; numbers and NULL do not.

Q24.

Rules applied on columns to keep the data valid are called:

Explanation

Constraints restrict what values can be stored.

Q25.

Which constraint makes sure a column cannot be left empty?

Explanation

NOT NULL means a value must always be given.

Q26.

Which constraint makes sure no two rows have the same value in a column, but allows NULL?

Explanation

UNIQUE prevents duplicates; PRIMARY KEY also prevents NULL.

Q27.

PRIMARY KEY is a combination of:

Explanation

A primary key value must be unique and cannot be NULL.

Q28.

How many PRIMARY KEY constraints can a table have?

Explanation

A table has only one primary key.

Q29.

Which constraint gives a column a value automatically when none is given?

Explanation

Example: City VARCHAR(20) DEFAULT 'Kolkata'.

Q30.

Which command creates a new database named SCHOOL?

Explanation

CREATE DATABASE name; creates a database.

Q31.

Which command lists all databases?

Explanation

SHOW DATABASES shows every database on the server.

Q32.

Which command opens (selects) the database SCHOOL for use?

Explanation

USE makes a database the current one.

Q33.

Which command deletes the whole database SCHOOL?

Explanation

DROP DATABASE removes the database and all its tables.

Q34.

Which command lists all the tables in the current database?

Explanation

SHOW TABLES lists the tables of the database in use.

Q35.

Which command shows the STRUCTURE (columns and types) of table STUDENT?

Explanation

DESCRIBE (or DESC) shows each column's name, type and constraints.

Q36.

Which is the correct CREATE TABLE statement?

Explanation

Columns go inside brackets, separated by commas, each with a data type.

Q37.

In CREATE TABLE, column definitions are separated by:

Explanation

Example: (RollNo INT, Name VARCHAR(20)).

Q38.

Which command adds a new column Email to table STUDENT?

Explanation

ALTER TABLE ... ADD adds a column.

Q39.

Which command changes the data type of column Name to VARCHAR(40)?

Explanation

ALTER TABLE ... MODIFY changes a column's definition.

Q40.

Which command removes the column Phone from STUDENT?

Explanation

ALTER TABLE ... DROP removes a column.

Q41.

Which command makes RollNo the primary key of an existing table STUDENT?

Explanation

ADD PRIMARY KEY (column) adds the constraint.

Q42.

Which command removes the primary key from STUDENT?

Explanation

A table has only one primary key, so no column name is needed.

Q43.

Which command deletes the table STUDENT completely (structure and data)?

Explanation

DROP TABLE removes the whole table.

Q44.

Which command adds a new row to a table?

Explanation

INSERT INTO table VALUES (...) adds a record.

Q45.

Which is a correct INSERT statement?

Explanation

Text values go in single quotes; values follow the column order.

Q46.

When values are given for ALL columns, the values must be in:

Explanation

Without a column list, values must match the table's column order.

Q47.

INSERT INTO Student (RollNo, Name) VALUES (10, 'Ravi'); What will the other columns contain?

Explanation

Columns not mentioned get NULL, or their DEFAULT value if one is set.

Q48.

How do you insert several rows with ONE INSERT statement in MySQL?

Explanation

VALUES (1, 'A'), (2, 'B'), (3, 'C'); inserts three rows.

Q49.

Which value can be written without quotes in INSERT?

Explanation

NULL is a keyword and is written without quotes.

Q50.

Inserting a row with a RollNo that already exists (RollNo is the PRIMARY KEY) will:

Explanation

A primary key value must be unique.

Q51.

Which statement about DDL and DML is TRUE?

Explanation

CREATE/ALTER/DROP work on structure; INSERT/UPDATE/DELETE work on data.

Q52.

Which is an advantage of SQL?

Explanation

SQL is easy to learn and is the standard language for relational databases.

Q53.

Which data type is best for a column storing a student's date of birth?

Explanation

DATE stores dates in 'YYYY-MM-DD' format.

Q54.

A column Price must store values like 1250.75 exactly. Which data type is best?

Explanation

DECIMAL stores exact numbers with a fixed number of decimal places.