Class 11 Informatics Practices Chapter 8 Introduction to Structured Query Language SQL NCERT Exercise Solution

CBSE NCERT Exercise Solution of Class 11 Informatics Practices


Chapter 8 – Introduction to Structured Query Language (SQL)


A quick revision


Database is a collection of related tables. MySQL is a ‘relational’ DBMS. A table is a collection of rows and columns, where each row is a record and columns describe the feature of records.
SQL is the standard language for most RDBMS. SQL is case insensitive.
CREATE DATABASE statement is used to create a new database.
USE statement is used for making the specified database as active database.
CREATE TABLE statement is used to create a table.
• Every attribute in a CREATE TABLE statement must have a name and a datatype.
ALTER TABLE statement is used to make changes in the structure of a table like adding, removing or changing datatype of column(s).
• The DESC statement with table name shows the structure of the table.
INSERT INTO statement is used to insert record(s) in a table.
UPDATE statement is used to modify existing data in a table.
DELETE statement is used to delete records in a table.

• The SELECT statement is used to retrieve data from one or more database tables.
SELECT * FROM table_name displays data from all the attributes of that table.
• The WHERE clause is used to enforce condition(s) in a query.
DISTINCT clause is used to eliminate repetition and display the values only once.
• The BETWEEN operator defines the range of values inclusive of boundary values.
• The IN operator selects values that match any value in the given list of values.
NULL values can be tested using IS NULL and IS NOT NULL.
ORDER BY clause is used to display the result of an SQL query in ascending or descending order with respect to specified attribute values. The default is ascending order.
LIKE clause is used for pattern matching. % and _ are two wild card characters. The percent (%) symbol is used to represent zero or more characters. The underscore (_) symbol is used to represent a single character.


NCERT Exercise Solution Ch 8 – SQL

Introduction to Structured Query Language NCERT Exercise Solution

1. Match the following clauses with their respective functions.

ALTERInsert the values in a table
UPDATERestrictions on columns
DELETETable definition
INSERT INTOChange the name of a column
CONSTRAINTSUpdate existing information in a table
DESCDelete an existing row from a table
CREATECreate a database

Answer:

ALTERChange the name of a column
UPDATEUpdate existing information in a table
DELETEDelete an existing row from a table
INSERT INTOInsert the values in a table
CONSTRAINTSRestrictions on columns
DESCTable definition
CREATECreate a database

2. Choose appropriate answer with respect to the following code snippet.

CREATE TABLE student ( name CHAR(30), student_id INT, gender CHAR(1), PRIMARY KEY (student_id) );

a) What will be the degree of student table?
i) 30
ii) 1
iii) 3
iv) 4

Answer: iii) 3

b) What does ‘name’ represent in the above code snippet?
i) a table
ii) a row
iii) a column
iv) a database

Answer: iii) a culumn

c) What is true about the following SQL statement?
Select * from student;
i) Displays contents of table ‘student’
ii) Displays column names and contents of table ‘student’
iii) Results in error as improper case has been used
iv) Displays only the column names of table ‘student’

Answer: i) Displays contents of table ‘student’ and ii) Displays column names and contents of table ‘student’.

d) What will be the output of following query?
INSERT INTO student
VALUES (“Suhana”,109,’F’),
VALUES (“Rivaan”,102,’M’),
VALUES (“Atharv”,103,’M’),
VALUES (“Rishika”,105,’F’),
VALUES (“Garvit”,104,’M’),
VALUES (“Shaurya”,109,’M’);
i) Error
ii) No Error
iii) Depends on compiler
iv) Successful completion of the query

Answer: i) Error

e) In the following query how many rows will be deleted?
DELETE student WHERE student_id=109;
i) 1 row
ii) All the rows where student ID is equal to 109
iii) No row will be deleted
iv) 2 rows

Answer: i) 1 row


NCERT Book Exercise Solution – Class 11 Informatics Practices

You cannot copy content of this page

Scroll to Top