1 / 7

Recap of SQL

Recap of SQL. Lab no. 7 Advance Database Management System. Lab Outline. Recap of SQL CREATE TABLE command. CREATE Command. CREATE TABLE <table name> (<column specification> , <column specification>… ). CREATE Command. <table name> It is the name of the table being created

zeph-nieves
Download Presentation

Recap of SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recap of SQL Lab no. 7 Advance Database Management System

  2. Lab Outline • Recap of SQL • CREATE TABLE command

  3. CREATE Command • CREATE TABLE <table name> (<column specification> , <column specification>… )

  4. CREATE Command • <table name> • It is the name of the table being created • <column specification> • It is the specification of a column • It consists of • Column name • Column data type • Size (length) associated with data type • Columns can be key or non key columns • Key columns are PKs or FKs and have a special ‘constraint’ tag specified in their definition

  5. Example CREATE TABLE Course ( CourseID CHAR(6) NOT NULL, CourseDsc VARCHAR(50) CONSTRAINT PK_1 PRIMARY KEY(CourseID), CONSTRAINT U_1 UNIQUE(CourseDsc) )

  6. Example • The following slides show CREATE TABLE command examples. • The first one shows creation of a table named ‘Course’. • The second example shows creation of a table ‘StudentCourse’ which takes FKs from ‘Course’ and another table ‘Student’ • PK and FK definitions are elaborated in the examples.

  7. Example CREATE TABLE StudentCourse ( StdID VARCHAR(10) NOT NULL, CourseID CHAR(6) NOT NULL, CourseDsc VARCHAR(50) CONSTRAINT PK_1 PRIMARY KEY(CourseID), CONSTRAINT U_1 UNIQUE(CourseDsc), CONSTRAINT FK_1 FOREIGN KEY(StdID) REFERENCES Student, CONSTRAINT FK_2 FOREIGN KEY(CourseID) REFERENCES Course )

More Related