0% found this document useful (0 votes)
10 views3 pages

Set 03

Uploaded by

Abinaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Set 03

Uploaded by

Abinaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Questions Set-03

1. What is the syntax used to comment on single lines and Multiple Line?
Ans:
Single lines comments: --Today is the 2nd session
Multiple Line comments:
/*
Today is
the 2nd
Session
*/

2. Write the syntax to create the ‘Training’ Database.


Ans: CREATE DATABASE Training

3. Create an employee table and insert the below data.

Ans: create table employee


(
EmpID int,
FirstName varchar(100),
LastName varchar(100),
Salary int,
Address varchar(100)
);

insert into employee values(1,'Mohan','Chauhan',22000,'Delhi')


insert into employee values(2,'Asif','Khan',15000,'Delhi')
insert into employee values(3,'Bhuvnesh','Shankya',19000,'Noida')
insert into employee values(4,'Deepak','Kumar',19000,'Noida')
SQL Questions Set-03

4. Add additional column MobileNumber on Employee table and add data on the
same column.
Ans: alter table employee add MobileNumber Bigint;

update employee
set MobileNumber = 0406309415
where EmpID = 1

update employee
set MobileNumber = 0452238834
where EmpID = 2

update employee
set MobileNumber =0403070636
where EmpID = 3

update employee
set MobileNumber = 0412356789
where EmpID = 4

5. How to Remove the address column from the employee table.


Ans:
alter table employee
drop column address

6. Write a query to Update Firstname = Ragu and LastName = Shayam for empID
=2.
Ans:
update employee
set FirstName='ragu',
LastName='Shayam'
where empid=2;

7. Write a query to Remove empid = 4 from the table.


Ans: delete from employee where EmpID=4

8. Write a query to update DimEmployee to store 500 length characters for the
column Title.
SQL Questions Set-03

Ans:

Alter table DimEmployee


Alter column Title varchar(500)

9. Create a duplicate table of DimCustomer With data.


Ans: Select * into DimCustomerDup from DimCustomer

10. Create a duplicate table of DimCustomer without any data.


Ans:
Select * into DimCustomer_Dup from DimCustomer where 2=3
Note: We can put any false condition in where clause

You might also like