0% found this document useful (0 votes)
87 views1 page

Lab Exercise 10

This document discusses using data definition language (DDL) statements to create and manage tables. It shows the DDL to create three tables: SUBJECTS with a primary key field of Subject_Id and title field with a not null constraint; SUBJ_TEACH with a primary key of ST_Id and foreign key fields referencing the SUBJECTS and TEACHERS tables; and TEACHERS with a primary key of Teacher_Id and first and last name fields with not null constraints.

Uploaded by

NoName Knight
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)
87 views1 page

Lab Exercise 10

This document discusses using data definition language (DDL) statements to create and manage tables. It shows the DDL to create three tables: SUBJECTS with a primary key field of Subject_Id and title field with a not null constraint; SUBJ_TEACH with a primary key of ST_Id and foreign key fields referencing the SUBJECTS and TEACHERS tables; and TEACHERS with a primary key of Teacher_Id and first and last name fields with not null constraints.

Uploaded by

NoName Knight
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/ 1

Lab Exercise 10: Using DDL Statements to Create and Manage Tables

CREATE TABLE SUBJECTS(


Subject_Id LONG
CONSTRAINT subject_id_pk PRIMARY KEY,
Title VARCHAR2
CONSTRAINT title_nn NOT NULL
);

CREATE TABLE SUBJ_TEACH(


ST_Id LONG
CONSTRAINT st_id_pk PRIMARY KEY,
Subject_Id LONG
CONSTRAINT subject_id_fk REFERENCES SUBJECTS(Subject_Id),
Teacher_Id LONG
CONSTRAINT teacher_id_fk REFERENCES TEACHERS(Teacher_Id),
Group_Id LONG
CONSTRAINT group_id_fk REFERENCES GROUPS(Group_Id)
);

CREATE TABLE TEACHERS(


Teacher_Id LONG
CONSTRAINT teacher_id_pk PRIMARY KEY,
FirstName VARCHAR2
CONSTRAINT firstname_nn NOT NULL,
LastName VARCHAR2
CONSTRAINT lastname_nn NOT NULL
);

You might also like