Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

SQL

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1. If a table which has one Primary key and two alternate keys.

How many
Candidate keys will this table have?
(A) 1
(B) 2
(C) 3
(D) 4

(C) 3

2 Which SQL command can change the degree of an existing relation?

Alter (or Alter Table)

3 In which datatype the value stored is padded with spaces to fit the specified length. (A) DATE
(B) VARCHAR (C) FLOAT (D) CHAR

(D) CHAR

4 Which aggregate function can be used to find the cardinality of a table? (A) sum() (B) count()
(C) avg() (D) max()

(B) count()

5 Assertion (A): A SELECT command in SQL can have both WHERE and HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check conditions, therefore, these
can be used interchangeably.

(C) A is True but R is False.

6 A) What constraint should be applied on a table column so that duplicate values are not
allowed in that column, but NULL is allowed.
OR
B) What constraint should be applied on a table column so that NULL is not allowed in that
column, but duplicate values are allowed.

(I) A) UNIQUE OR B) NOT NULL (1 mark for correct answer)

7. A) Write an SQL command to remove the Primary Key constraint from a table, named
MOBILE. M_ID is the primary key of the table.
OR
B) Write an SQL command to make the column M_ID the Primary Key of an already existing
table, named MOBILE.

A) ALTER TABLE MOBILE DROP PRIMARY KEY;


OR
B) ALTER TABLE MOBILE ADD PRIMARY KEY (M_ID);
8

IV) Display the sum of Price of all the orders for which the quantity is null.

(I) select Product, sum(Quantity) from orders group by product having sum(Quantity)>=5;
(II) select * from orders order by Price desc;
(III) select distinct C_Name from orders;
(IV) select sum(price) as total_price from orders where Quantity IS NULL;

9 Write the output


(I) Select c_name, sum(quantity) as total_quantity from orders group by c_name;
(II) Select * from orders where product like '%phone%';
(III) Select o_id, c_name, product, quantity, price from orders where price between
1500 and 12000;
(IV) Select max(price) from orders;
7
(I) Select * from FACULTY natural join COURSES where Salary<12000;
Or Select * from FACULTY, COURSES where Salary<12000 and facuty.f_id=courses.f_id;
(II) Select * from courses where fees between 20000 and 50000;

(III) Update courses set fees=fees+500 where CName like '%Computer%';

(IV) (A) Select FName, LName from faculty natural join courses where Came="System
Design";
Or Select FName, LName from faculty, courses where Came="System Design" and
facuty.f_id=courses.f_id;

OR (B) Select * from FACULTY, COURSES;


8

You might also like