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

week 7

Uploaded by

jawadkh8180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

week 7

Uploaded by

jawadkh8180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

NAME Khaista Rehman

ID CU-4276-2023

CLASS BSSE

SECTION B

SUBMITTED TO Sir Arshad Iqbal

DATE 28-5-2024
SQL> alter table customers drop primary key;

Table altered.

SQL> alter table customers add constraint pk primary key(id);


Table altered.

SQL> alter table customers drop constraint pk;

Table altered.

SQL> create table student(id number(4) primary key,name varchar(15),age


number(3));

Table created.

SQL> create table subject(id number(4),sub_name varchar(15));

Table created.

SQL> alter table subject add foreign key(id) references student(id);

Table altered.

SQL> desc customers;


Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(4)
NAME NOT NULL VARCHAR2(20)
ADDRESS VARCHAR2(25)
SALARY NUMBER(8,2)

SQL> alter table customers modify salary number(8,2) default 5000;


Table altered.

SQL> desc customers;


Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(4)
NAME NOT NULL VARCHAR2(20)
ADDRESS VARCHAR2(25)
SALARY NUMBER(8,2)

SQL> alter table customers modify (salary default null);

Table altered.

SQL> desc customers;


Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(4)
NAME NOT NULL VARCHAR2(20)
ADDRESS VARCHAR2(25)
SALARY NUMBER(8,2)

SQL> alter table customers modify salary number(8,2) default 5000;

Table altered.

SQL> insert into customers (id, name,address) values (1, 'abcd', 'pesh');

1 row created.
SQL> select * from customers;

ID NAME ADDRESS SALARY


---------- -------------------- ------------------------- ----------
1 abcd pesh
1 abcd pesh 5000

SQL> alter table customers modify (salary default null);

Table altered.

SQL> insert into customers (id, name,address) values (1, 'abcd', 'pesh');

1 row created.

SQL> select * from customers;

ID NAME ADDRESS SALARY


---------- -------------------- ------------------------- ----------
1 abcd pesh
1 abcd pesh 5000
1 abcd pesh

You might also like