Vous êtes sur la page 1sur 6

I.

Create the following tables:


TABLE : STUDENT
COLUMN NAME DATA TYPE CONSTRAINTS
Roll_no Number(5) Primary Key
Name Varchar(20) Not null
Dept_name Varchar(20)
Gender Varchar(2)
Contact_no Number(10)

Write SQL queries for the following


1) Insert 5 records to the table
2) Display details of all students
3) Display details of all Female students
4) Find rollno, name of all students from a particular department
5) Find name and contactno of all Male students

2.Create the following tables:


TABLE :BOOK
COLUMN NAME DATA TYPE CONSTRAINTS
BookID Varchar(6) Primary Key
BookName Varchar(15) Not null
Author_Name Varchar(15)
Publisher Varchar(20)
Unit_price Number(8,2) Not null,cannot be zero
Quantity Number(3)
Write SQL queries for the following
1) Insert 5 records to the table
2) Display details of all books
3) Display details of all books from a particular Author
4) Find BookName, Price of all books from a particular Publisher
5) Find BookID, Bookname and Quantity of books whose price is between 200
and 500.
6) Find the details of book from a particular publisher and unit_price above 500.
7) Find the Totalprice of each book. (Totalprice=unitprice* quantity)

SQL LAB
Set I
3.Create the following tables:
TABLE : STUDENT
COLUMN NAME DATA TYPE CONSTRAINTS
Roll_no Number(5) Primary Key
Name Varchar(20) Not null
Dept_id Number(5) Foreign Key
Gender Varchar(2)
Contact_no Number(10)

TABLE : DEPARTMENT
COLUMN NAME DATA TYPE CONSTRAINTS
Dept_id Number(5) Primary Key
Dept_name Varchar(10) Not null

Write SQL queries for the following


1. a. Insert 5 records in each table
b. Update the contact number of student with Roll_no 005
2. a. Display the data of female students in alphabetical order.
b. Find the number of students in Electrical Department
c. Find department id and no. of students from each deptid
d. Find rollno ,name and department name of all students
e. Find name and contactno of all male students from bca department.

4.Create the following tables:


TABLE: CUSTOMER
Column name Data type Size Constraints
Cust_id Varchar 10 Primary Key
Fname Varchar 25 Not Null
Lname Varchar 25
Area Varchar 10 Kottayam ,Kollam, Kochi
Phone_number Numeric 15

TABLE : INVOICE

Column Name Data type Size Constraints

Inv_no Varchar 20 Primary Key

Cust_id Varchar 10 Foreign Key


Issue_date Date

Write SQL queries for the following:


1. a. Insert 5 records in each table
b. Change the issue date to 24/7/08 of cust_id 101
2. a. Find the issue date for the customer JOHNS.
b. List the customer name and invoice number of all customers
a. Find the lnames of all customers that begin with P or B.
b. List the customer details in the alphabetical order of their name

SQL LAB
Set I
5.Create the following tables:
TABLE : STUDENT
COLUMN NAME DATA TYPE CONSTRAINTS
Roll_no Number(5) Primary Key
Name Varchar(20) Not null
Dept_id Number(5) Foreign Key
Gender Varchar(2)
Contact_no Number(10)

TABLE : DEPARTMENT
COLUMN NAME DATA TYPE CONSTRAINTS
Dept_id Number(5) Primary Key
Dept_name Varchar(10) Not null

Write SQL queries for the following


1. a. Insert 5 records in each table
b. Update the contact number of student with Roll_no 005
2. a. Display the data of female students in alphabetical order.
b. Find the number of students in Electrical Department
6.Create the following tables:
TABLE: CUSTOMER
Column name Data type Size Constraints
Cust_id Varchar 10 Primary Key
Fname Varchar 25 Not Null
Lname Varchar 25
Area Varchar 10 Kottayam ,Kollam, Kochi
Phone_number Numeric 15

TABLE : INVOICE

Column Name Data type Size Constraints

Inv_no Varchar 20 Primary Key

Cust_id Varchar 10 Foreign Key

Issue_date Date

Write SQL queries for the following:


3. a. Insert 5 records in each table
b. Change the issue date to 24/7/08 of cust_id 101
4. a. Find the issue date for the customer JOHNS.
b. List the customer name and invoice number of all customers
c. Find the lnames of all customers that begin with P or B.
d. List the customer details in the alphabetical order of their name
SQL LAB
Set I
7.Create the following tables:
TABLE : STUDENT
COLUMN NAME DATA TYPE CONSTRAINTS
Roll_no Number(5) Primary Key
Name Varchar(20) Not null
Dept_id Number(5) Foreign Key
Gender Varchar(2)
Contact_no Number(10)
TABLE : DEPARTMENT
COLUMN NAME DATA TYPE CONSTRAINTS
Dept_id Number(5) Primary Key
Dept_name Varchar(10) Not null

Write SQL queries for the following


3. a. Insert 5 records in each table
b. Update the contact number of student with Roll_no 005
4. a. Display the data of female students in alphabetical order.
b. Find the number of students in Electrical Department
c.find deptid and no of students from each deptid
d.find rollno,name and department name of all students
e.find contactno and name of all male students from bca dept.

8.Create the following tables:


TABLE: CUSTOMER
Column name Data type Size Constraints
Cust_id Varchar 10 Primary Key
Fname Varchar 25 Not Null
Lname Varchar 25
Area Varchar 10 Kottayam ,Kollam, Kochi
Phone_number Numeric 15

TABLE : INVOICE

Column Name Data type Size Constraints

Inv_no Varchar 20 Primary Key

Cust_id Varchar 10 Foreign Key

Issue_date Date

Write SQL queries for the following:


5. a. Insert 5 records in each table
b. Change the issue date to 24/7/08 of cust_id 101
6. a. Find the issue date for the customer JOHNS.
b. List the customer name and invoice number of all customers
e. Find the lnames of all customers that begin with P or B.
f. List the customer details in the alphabetical order of their name

Vous aimerez peut-être aussi