You are on page 1of 25

2011

DATABASE MANAGEMENT SYSTEMS LAB

Diksha Gupta 016070102709 B.Tech CSE

Experiment No. 1
Introduction to SQL - its Features and Benefits It stands for Structured Query Language.SQL is both an easy-to-understand language and a comprehensive tool for managing data. Here are some of the major features of SQL and the market forces that have made it successful: Vendor Independence SQL is offered by all of the leading DBMS vendors, and no new database product over the last decade has been highly successful without SQL support. A SQLbased database and the programs that use it can be moved from one DBMS to another vendors DBMS with minimal conversion effort and little retraining of personnel. Database tools, such as query tools, report writers, and application generators, work with many different brands of SQL databases. The vendor independence thus provided by SQL was one of the most important reasons for its early popularity and remains an important feature today. Portability across Computer Systems SQL-based database products run on computer systems ranging from mainframes and midrange systems to personal computers, workstations, a wide range of specialized server computers, and even handheld devices. They operate on standalone computer systems, in departmental local area networks, and in enterprise wide or Internet wide networks. SQL-based applications that begin on single-user or departmental server systems can be moved to larger server systems as they grow. Data from corporate SQL-based databases can be extracted and downloaded into departmental or personal databases. Finally, economical personal computers can be used to prototype a SQL-based database application before moving it to an expensive multiuser system. SQL Standards An official standard for SQL was initially published by the American National Standards Institute (ANSI) and the International Standards Organization (ISO) in

DIKSHA GU

1986, and was expanded in 1989 and again in 1992 and 1999. SQL is also a U.S. Federal Information Processing Standard (FIPS), making it a key requirement for large government computer contracts. Over the years, other international, government, and vendor groups have pioneered the standardization of new SQL capabilities, such as call-level interfaces or object-based extensions. Many of these new initiatives have been incorporated into the ANSI/ISO standard over time. The evolving standards serve as an official stamp of approval for SQL and have speeded its market acceptance.

DIKSHA GU

Experiment No. 2 Write SQL queries to create a table, Insert values, alter the table structure, modify the values of the table and view the record of the table. a) Table : client_master

DIKSHA GU

b) Table: product_master

DIKSHA GU

DIKSHA GU

c) Table: salesman_master

DIKSHA GU

d)

Table: sales_order_details

DIKSHA GU

DIKSHA GU

e) Table: sales_order

DIKSHA GU

DIKSHA GU

f) Exercise to retrieve records i. Find out the names of all the clients.

ii. Retrieve the entire contents of the Client_master table.

DIKSHA GU

iii. Retrieve the list of names and the cities of all the clients.

iv. List the various products available from the Product_master table.

v. List all the clients who are located in Mumbai.

DIKSHA GU

vi. Find the names of the Saleman who have a salary equal to Rs.3000.

g) Exercise on updating records in a table. i. Change the City from Bombay to Mumbai.

DIKSHA GU

h) Exercise on deleting records in a table: i. Delete all salesman from the Salesman_master whose values are equal to Rs.3500.

ii.

Delete from Client_master where the column state holds the value Tamil Nadu.

DIKSHA GU

i) Exercise on altering table structure: i. Add a column called telephone of the datatype number and size=10 to the Client_master table.

j) Exercise on deleting the table structure: a) Destroy the table Client_master1 (a replica of Client_master) along with its data.=

DIKSHA GU

j) Exercise on renaming the table: a) Change the name of the Salesman_master to sman_mast.

DIKSHA GU

Experiment No. 3
Write SQL queries using logical operators: and, or, in, not in, pattern matching (like) and performing arithmetic calculations. a) Retrieve the contents of the column product_no, description and compute 5% of the values contained in the column sell_price and 105% of the values contained in the field sell_price for each row of Product_master.

b) Retrieve Client information for clients having pincode as 400045 or 400057.

DIKSHA GU

c) Retrieve client information for clients who are not in Bombay or Delhi.

d) Retrieve details of product where profit % is between 10 and 20.

DIKSHA GU

e) Retrieve information of clients whose name starts with a.

f) Retrieve the information of clients where second character of the name is a or r.

g) List all the clients who stay in Bangalore or Mangalore.

DIKSHA GU

h) List all the information from Sales_Order table for orders placed in the month of June.

i) List the order of information of Client_no C0001 and C0002.

DIKSHA GU

j) List products whose selling price is greater than 500 and less than or equal to 750.

k) List products whose selling price is more than 500.Calculate a new selling price as original selling price * 0.15. Rename the new column as output of above as new_price.

DIKSHA GU

l) List names, city and state of clients who are not in the state of Maharastra.

DIKSHA GU

Experiment No. 4
Write SQL queries using numeric functions: count, max, min and avg. a) Calculate average price of all the products.

b) Count the total no. of orders.

c) Determine Max and Min product prices. Rename output as max_price and min_price.

DIKSHA GU

d) Count number of products whose price is less than or equal to 500.

e) List all the products whose qty_on_hand is less than reorder level.

DIKSHA GU

You might also like