Lab7 Constraints2
Lab7 Constraints2
Course: BCA
1. WAQ (write a query) to create an “Account” table with following constraints:
All constraints to be given ONLY 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 created table using “describe”. (Note structure carefully)
and write answers for 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 constrain?.
3. See the contents of “User_Constraints” table and note the constraint number and type
of constraints for your above table. (You can attach printout of this table)
4. Insert the following data in the above table (In case of Error , Correct the data yourself)
Write Each Query without using substitution and note the output of each.
6. See and note the structure of above created table using “describe”. (Note structure carefully)
8. See the contents of “User_Constraints” table and note the constraint number and type
of constraints for your above tables.
10. WAQ (write a query) to create an “Account4” table with following constraints:
11. See the contents of “User_Constraints” table and note the constraint number and type
of constraints for your above table.
12. Drop the Primary Key & Unique Constraint from Account4 Table.
13. WAQ (write a query) to create an “Account5” table without any constraints:
16. Add the primary key constraint for AccountNo in Account5 Table
(If an error comes, note the error and write the reason)
17. In case of error in above ques, rectify the above table contents and repeat above Question
(Write all the steps and queries)
18. See the contents of “User_Constraints” table and search the name of Account5 table in it.
20. Add Check constraint in Account5 Table for Balance field. ( Amount > 1500)
21. In case of error in above ques, rectify the above table contents and repeat above Question
(Write all the steps and queries)
22. See the contents of “User_Constraints” table and search the name of Account5 table in it.
(Note the constraint number for account5 table)