Advertisement
mahmud_bhai

lab1

Mar 15th, 2021
1,364
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1.
  2.  
  3. CREATE TABLE department(
  4. deptid NUMBER(3) CONSTRAINT dept_id_pk PRIMARY KEY,
  5. dept_name VARCHAR (6) CONSTRAINT name_ck CHECK(dept_name IN('CSE','EEE','BBA','Eng','Ach')),
  6. budget NUMBER(6) DEFAULT 0
  7. )
  8.  
  9. 2.
  10. CREATE TABLE course(
  11. crs_id NUMBER(4) CONSTRAINT crs_id_pk PRIMARY KEY,
  12. crs_name VARCHAR2(6) NOT NULL,
  13. deptid NUMBER(3) CONSTRAINT fk_deptid REFERENCES department(deptid)
  14. )
  15.  
  16. EDIT PART
  17.  
  18. 1.
  19. CREATE TABLE test(
  20. s_id    NUMBER(3),
  21. s_name  VARCHAR2(20),
  22. Phone NUMBER(11),
  23. Address VARCHAR2(50),
  24. Email   VARCHAR2(30),
  25. credit_completed    NUMBER(3),
  26. course_completed    NUMBER(2),
  27. Cgpa    NUMBER(3,2),
  28. Deptno  NUMBER(5),
  29. Gender  VARCHAR2(6)
  30. )
  31.  
  32. 2.ALTER TABLE test ADD CONSTRAINT pk_s_id PRIMARY KEY (s_id)
  33. 3.ALTER TABLE test MODIFY s_name VARCHAR2(20) NOT NULL
  34. 4.ALTER TABLE test MODIFY email VARCHAR2(30) UNIQUE
  35. 5.ALTER TABLE test ADD CONSTRAINT ck_dptid foreign KEY(Deptno) REFERENCES department(deptid)
  36. 6.ALTER TABLE test ADD CONSTRAINT ck_gender CHECK(gender IN('M','F'))
  37. 7.ALTER TABLE test disable CONSTRAINT pk_s_id
  38. 8.ALTER TABLE test DROP CONSTRAINT ck_gender
  39. 9.SELECT constraint_name, column_name FROM user_cons_columns WHERE
  40. table_name = 'TEST'
  41. 10.ALTER TABLE test enable CONSTRAINT pk_s_id
  42.  
Advertisement
RAW Paste Data Copied
Advertisement