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

Practical 7

Uploaded by

Gautam Bhatnagar
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)
23 views3 pages

Practical 7

Uploaded by

Gautam Bhatnagar
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

DBMS Practical List - 7

Platform: Oracle Express


Implementation of Constraints 1

1. Write a query to create an account table with following constraints:


ALL CONSTRAINTS TO BE GIVEN AT COLUMN LEVEL
AccountNo Number Primary Key
CustName Varchar2 Not Null
AccountType Varchar2 Default Value ‘Saving’
Balance Number >1000
PassportNo Varchar2 Unique
2. See and note the structure of above table, and answer the following questions:
a) Which constraints are displayed in the structure?
b) Can you tell from the structure which column is unique?
c) Can you tell from the structure which column is Primary and which Not Null?
d) Can you tell from the structure which column has check constraint?
3. Insert the following data in the table:

117501 Puneet Saving 1100 B9895


117502 Saving 2100 A9895
117507 Rohit Current 500 C9898
117507 Rohit Current 5000 C9898
117504 Kumar 1100 C9898
117508 Shweta 7100 A6789
117503 Deepak Current 12000

Note the output of each query

Commit the Data


4. WAQ to create an “Account2” table with following constraints:
AccountNo Number Primary Key
CustName Varchar2 Not Nul
AccountType Varchar2 Default Value ‘Current’
Balance Number >5000
PassportNo Varchar2 Unique

5. See and note the structure of above table.


6. Write a query to create an “Account3” table with following constraints:
AccoutNo Number Primary Key(at row/table level)
CustName Varchar2 Not Null(only at table/row level)
If an error occurs, note the error and rectify it.
7. See the contents of “User_Constraints” table and note the constraint number and type
the constraintsfor above table.
8. Drop the Not Null constraint from “Account3” table.
9. WAQ to create an “Account4” table with following constraints:
AccountNo Number Primary Key (Constraint Name: Pkey)
CustName Varchar2 Not Null (Constraint Name: NNull)
AccountType Varchar2 Default Value ‘Current’
Balance Number >5000 (Constraint Name: ChkBal)
PassportNo Varchar2 Unique (Constraint Name: UU)

10. See the contents of “User_Constraints” of above table.


11. Drop the Primary Key & Unique Constraint from Account4 table.
12. WAQ to create an “Account5” table without any consrtaints:
AccountNo Number
CustName Varchar2
Balance Number

13. See the structure of above table.


14. Add primary key constraint for AccountNo in Account5 table.
(In case of error rectify the table contents and repeat the question)
15. Add Unique constraint in the table for CustName field.
16. Add Check constraint in the table for Balance field (Amount > 1500)
(In case of error rectify the table contents and repeat the question)
17. Display the data in Account5 table, also record its structure.

You might also like