0% found this document useful (0 votes)
29 views6 pages

Relational Data Model and CREATE TABLE Statement

The document discusses the SQL CREATE TABLE statement, including its syntax and examples. It explains that the CREATE TABLE statement is used to define a table with column specifications and data types. It provides an example CREATE TABLE statement defining columns for a Student table. It also lists common SQL data types that can be used in column definitions such as CHAR, VARCHAR, INTEGER, DECIMAL.

Uploaded by

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

Relational Data Model and CREATE TABLE Statement

The document discusses the SQL CREATE TABLE statement, including its syntax and examples. It explains that the CREATE TABLE statement is used to define a table with column specifications and data types. It provides an example CREATE TABLE statement defining columns for a Student table. It also lists common SQL data types that can be used in column definitions such as CHAR, VARCHAR, INTEGER, DECIMAL.

Uploaded by

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

Information Systems Program

Module 3
Relational Data Model and
CREATE TABLE Statement

Lesson 3: Basics of the SQL CREATE TABLE


Statement
Lesson Objectives
• Write CREATE TABLE statements with column
specifications including data types
• Read CREATE TABLE statements to see
columns and associated data types

Information Systems Program


CREATE TABLE Syntax
• CREATE TABLE <table-name> ( <column-list>
[<constraint-list>] )
• Column list with data types and optional and
inline constraints
• Optional external constraint list
– CONSTRAINT [ ConstraintName ] <Constraint-Spec>
– Primary key
– Foreign key
– Unique
– Check
3

Information Systems Program


CREATE TABLE Statement Example

CREATE TABLE Student


( StdNo CHAR(11),
StdFirstName VARCHAR(50),
StdLastName VARCHAR(50),
StdCity VARCHAR(50),
StdState CHAR(2),
StdZip CHAR(10),
StdMajor CHAR(6),
StdClass CHAR(6),
StdGPA DECIMAL(3,2) );

Information Systems Program


Common SQL Data Types
• CHAR(L)
• VARCHAR(L)
• INTEGER
• FLOAT(P)
• DECIMAL(W, R)
• Date/Time: DATE, TIME, TIMESTAMP
• BOOLEAN

Information Systems Program


Summary
• Important definitional statement
• Data types not always portable
• Somewhat tedious specification although
relatively portable
• Other interfaces for more productivity

Information Systems Program

You might also like