0% found this document useful (0 votes)
471 views

DDL DML Exercises

The document describes the structure of 4 tables - Customer, Product, Order, and ProdOrd with field names and data types. It provides instructions to: 1) Create the tables in SQL 2) Add/modify columns and constraints across the tables 3) Insert sample data 4) Commit transactions and demonstrate privileges

Uploaded by

Bravalu Macpha
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)
471 views

DDL DML Exercises

The document describes the structure of 4 tables - Customer, Product, Order, and ProdOrd with field names and data types. It provides instructions to: 1) Create the tables in SQL 2) Add/modify columns and constraints across the tables 3) Insert sample data 4) Commit transactions and demonstrate privileges

Uploaded by

Bravalu Macpha
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/ 2

Customer Table

CUSTOMER (CustomerNo, fname, lname, phone)


CustomerNo Primary key, numeric, 4 digits
Fname A variable character field up to 15
characters in length. Must have a value
Lname A variable character field up to 15
characters in length. Must have a value.
Phone A variable character field up to 12
characters in length.
Product Table
PRODUCT (ProdNo, description, cost)
ProdNo Primary key, numeric, 5 digits
Description A variable character field up to 20
characters in length.
Cost A floating number. Must have a value.
i.e: 125.85
Order Table (You are not allowed to use ORDER as table name since it is reserved
word!!!)
PORDER (orderNo, orderDate, city, postCode, customerNo)
OrderNo Primary key, numeric, 6 digits
OrderDate Date field that will include day, month
and year. (dd-mon-yyyy).
City A variable character field up to 20
characters in length. Must have a value.
Postcode A variable character field up to 10
characters. Must have a value.
ProdOrd Table
PRODORD (orderNo, prodNo, quantity, price)
OrderNo Forms part of the primary key, must
match a value in the ORDER table.
ProdNo Forms part of the primary key, must
match a value in the PRODUCT table.
quantity Numeric. 2 digits, greater than zero.

1- Use above specifications and create tables in SQL.

2- Write appropriate SQL statements to do the following steps.


 Add a new column to CUSTOMER table called ‘gender’. The column must contain a
single character field, either ‘M’ for male or ‘F’ for female. Must not be null.

 Add a new constraint to CUSTOMER table, so that combination of fname and lname
columns must be unique.

 Add a new column to PRODUCT table called ‘color’. The column must contain
variable character string up to 10 characters. Default color is ‘White’.

 CustomerNo must be foreign key in PORDER table. So add foreign key constraint to
PORDER table.

 Modify CUSTOMER table to increase the size of phone column to 15 characters.

 Modify ORDER table and add today’s date to be DEFAULT value for OrderDate
column.

 Drop postcode column from Order table.

3 – Insert at least 3 records in each of the tables.

4 – Commit your transactions till now.

5- Insert new records in PRODUCT table using the sequence that you have created above.

6 - Give SELECT & INSERT privileges to everyone in your class for PRODUCT table.

7- Give UPDATE privilege to the person sitting next to you on PORDER table.

8- Take back INSERT privilege from everyone.

9- Rollback to see the effect.

10- Drop all tables that you have created. (PORDER, PRODUCT, CUSTOMER, PRODORD)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy