SlideShare a Scribd company logo
SQL
Creating and Altering Tables
This is DDL
DDL - Data Definition Language
● Creating and Altering the structure of the
database.
● You are building the data dictionary!
CREATE TABLE
CREATE TABLE ARTISTS
(ARTIST_ID INT,
ARTIST_NAME
VARCHAR(60),
ARTIST_DOB DATE,
POSTER_IN_STOCK BOOLEAN);
Don’t Forget Data Types!
CHAR DATE
TIMESTAMP
VARCHAR TIME BOOLEAN
NUMERIC REAL
DECIMAL DOUBLE
INT PRECISION
SMALLINT FLOAT
User Defined (Data) Types
CREATE TYPE SALARY AS NUMERIC(8,2)
FINAL;
CREATE TABLE EMPLOYEES
(EMPLOYEE_ID
INTEGER,
EMPLOYEE_SALARY SALARY);
Default Values
CREATE TABLE ARTISTS
(ARTIST_ID INT,
ARTIST_NAME VARCHAR(60),
PLACE_OF_BIRTH VARCHAR(60)
DEFAULT ‘Unknown’);
ALTER TABLE
ALTER TABLE ARTISTS
ADD COLUMN ARTIST_DOB DATE;
ALTER COLUMN
ALTER TABLE ARTISTS
ALTER COLUMN PLACE_OF_BIRTH SET
DEFAULT ‘Unknown’;
ALTER TABLE ARTISTS
ALTER COLUMN PLACE_OF_BIRTH DROP
DEFAULT;
DROP COLUMN
ALTER TABLE ARTISTS
DROP COLUMN PLACE_OF_BIRTH
CASCADE;
DROP TABLE
DROP TABLE ARTISTS CASCADE;
Not the Same as:
TRUNCATE TABLE ARTISTS;
Or
DELETE * FROM ARTISTS;
Required or Optional?
CREATE TABLE CD_ARTISTS
(ARTIST_ID INT NOT NULL,
ARTIST_NAME VARCHAR(60) NOT NULL,
PLACE_OF_BIRTH VARCHAR(60));
Unique Constraints
CREATE TABLE CD_INVENTORY
(ARTIST_NAME VARCHAR(40),
CD_NAME VARCHAR(60),
COPYRIGHT INT,
CONSTRAINT UN_ARTIST_CD UNIQUE
(ARTIST_NAME, CD_NAME));
Primary Keys
CREATE TABLE CD_ARTISTS
(ARTIST_ID INT,
ARTIST_NAME VARCHAR(60),
AGENCY_ID INT,
CONSTRAINT PK_ARTIST_ID PRIMARY_KEY
(ARTIST_ID, ARTIST_NAME);
Foreign Keys
CREATE TABLE CD_TITLES
(CD_TITLE_ID INT,
CD_TITLE VARCHAR(60),
PUBLISHER_ID INT,
FK_PUBLISHER_ID FOREIGN KEY
(PUBLISHER_ID) REFERENCES CD_PUBLISHERS
(PUBLISHER_ID));
Column Constraints
CREATE TABLE CD_TITLES
(CD_TITLE INT,
CD_TITLE VARCHAR(60) NOT NULL,
IN_STOCK INT
NOT NULL,
CONSTRAINT CK_IN_STOCK
(IN_STOCK > 0 AND IN_STOCK < 30));

More Related Content

What's hot

Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
NITISH KUMAR
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
Md.Mojibul Hoque
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
Arun Sial
 
Restricting and sorting data
Restricting and sorting dataRestricting and sorting data
Restricting and sorting data
Syed Zaid Irshad
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
Anusha sivakumar
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
I L0V3 CODING DR
 
Sql ppt
Sql pptSql ppt
Sql ppt
Anuja Lad
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
Amrit Kaur
 
02 Writing Executable Statments
02 Writing Executable Statments02 Writing Executable Statments
02 Writing Executable Statments
rehaniltifat
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
DTD
DTDDTD
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Stored procedure
Stored procedureStored procedure
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
VARSHAKUMARI49
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 

What's hot (20)

Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
 
Restricting and sorting data
Restricting and sorting dataRestricting and sorting data
Restricting and sorting data
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
02 Writing Executable Statments
02 Writing Executable Statments02 Writing Executable Statments
02 Writing Executable Statments
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
DTD
DTDDTD
DTD
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL commands
SQL commandsSQL commands
SQL commands
 

Similar to SQL: Creating and Altering Tables

SESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdfSESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdf
budiman
 
Database
Database Database
SQL Presentation & explaination short I.pptx
SQL Presentation & explaination short I.pptxSQL Presentation & explaination short I.pptx
SQL Presentation & explaination short I.pptx
lankanking4
 
Introduction to sq lite
Introduction to sq liteIntroduction to sq lite
Introduction to sq lite
punu_82
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
 
Les09
Les09Les09
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
Steve Johnson
 
Les09
Les09Les09
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tables
Syed Zaid Irshad
 
JSON in MySQL and MariaDB Databases
JSON in MySQL and MariaDB DatabasesJSON in MySQL and MariaDB Databases
JSON in MySQL and MariaDB Databases
Federico Razzoli
 
SQL & PLSQL
SQL & PLSQLSQL & PLSQL
SQL & PLSQL
Prakash Poudel
 
Sql
SqlSql
SQL Reports in Koha
SQL Reports in KohaSQL Reports in Koha
SQL Reports in Koha
Nicole C. Engard
 
Actividad 1
Actividad 1Actividad 1
Actividad 1
JUAN ENRIQUE
 
SQL structure query language full presentation
SQL structure query language full presentationSQL structure query language full presentation
SQL structure query language full presentation
JKarthickMyilvahanan
 
Constraints
ConstraintsConstraints
Constraints
punu_82
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
lilredlokita
 
CS121Lec04.pdf
CS121Lec04.pdfCS121Lec04.pdf
CS121Lec04.pdf
georgejustymirobi1
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
Mukesh Tekwani
 
Ch6(mysql front)
Ch6(mysql front)Ch6(mysql front)
Ch6(mysql front)
Chhom Karath
 

Similar to SQL: Creating and Altering Tables (20)

SESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdfSESI 2 DATA DEFINITION LANGUAGE.pdf
SESI 2 DATA DEFINITION LANGUAGE.pdf
 
Database
Database Database
Database
 
SQL Presentation & explaination short I.pptx
SQL Presentation & explaination short I.pptxSQL Presentation & explaination short I.pptx
SQL Presentation & explaination short I.pptx
 
Introduction to sq lite
Introduction to sq liteIntroduction to sq lite
Introduction to sq lite
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Les09
Les09Les09
Les09
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
 
Les09
Les09Les09
Les09
 
Using ddl statements to create and manage tables
Using ddl statements to create and manage tablesUsing ddl statements to create and manage tables
Using ddl statements to create and manage tables
 
JSON in MySQL and MariaDB Databases
JSON in MySQL and MariaDB DatabasesJSON in MySQL and MariaDB Databases
JSON in MySQL and MariaDB Databases
 
SQL & PLSQL
SQL & PLSQLSQL & PLSQL
SQL & PLSQL
 
Sql
SqlSql
Sql
 
SQL Reports in Koha
SQL Reports in KohaSQL Reports in Koha
SQL Reports in Koha
 
Actividad 1
Actividad 1Actividad 1
Actividad 1
 
SQL structure query language full presentation
SQL structure query language full presentationSQL structure query language full presentation
SQL structure query language full presentation
 
Constraints
ConstraintsConstraints
Constraints
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
CS121Lec04.pdf
CS121Lec04.pdfCS121Lec04.pdf
CS121Lec04.pdf
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
 
Ch6(mysql front)
Ch6(mysql front)Ch6(mysql front)
Ch6(mysql front)
 

More from RJ Podeschi

The4PsDesigningMarketingCoursewithDisney_8-18-16
The4PsDesigningMarketingCoursewithDisney_8-18-16The4PsDesigningMarketingCoursewithDisney_8-18-16
The4PsDesigningMarketingCoursewithDisney_8-18-16
RJ Podeschi
 
Millikin I.S. Nerd Night 3-30-2016
Millikin I.S. Nerd Night 3-30-2016Millikin I.S. Nerd Night 3-30-2016
Millikin I.S. Nerd Night 3-30-2016
RJ Podeschi
 
Homecoming 2015 I.S. Announcements
Homecoming 2015 I.S. AnnouncementsHomecoming 2015 I.S. Announcements
Homecoming 2015 I.S. Announcements
RJ Podeschi
 
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
RJ Podeschi
 
SQL: The Language of Databases
SQL: The Language of DatabasesSQL: The Language of Databases
SQL: The Language of Databases
RJ Podeschi
 
SQL: Using Predicates
SQL: Using PredicatesSQL: Using Predicates
SQL: Using Predicates
RJ Podeschi
 
SQL: Querying Multiple Tables
SQL: Querying Multiple TablesSQL: Querying Multiple Tables
SQL: Querying Multiple Tables
RJ Podeschi
 

More from RJ Podeschi (7)

The4PsDesigningMarketingCoursewithDisney_8-18-16
The4PsDesigningMarketingCoursewithDisney_8-18-16The4PsDesigningMarketingCoursewithDisney_8-18-16
The4PsDesigningMarketingCoursewithDisney_8-18-16
 
Millikin I.S. Nerd Night 3-30-2016
Millikin I.S. Nerd Night 3-30-2016Millikin I.S. Nerd Night 3-30-2016
Millikin I.S. Nerd Night 3-30-2016
 
Homecoming 2015 I.S. Announcements
Homecoming 2015 I.S. AnnouncementsHomecoming 2015 I.S. Announcements
Homecoming 2015 I.S. Announcements
 
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
Field Trip Learning: Measuring Effectiveness, Transfer, & Metacognition in th...
 
SQL: The Language of Databases
SQL: The Language of DatabasesSQL: The Language of Databases
SQL: The Language of Databases
 
SQL: Using Predicates
SQL: Using PredicatesSQL: Using Predicates
SQL: Using Predicates
 
SQL: Querying Multiple Tables
SQL: Querying Multiple TablesSQL: Querying Multiple Tables
SQL: Querying Multiple Tables
 

Recently uploaded

一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
agdhot
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
keesa2
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
nhutnguyen355078
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
Vietnam Cotton & Spinning Association
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
1tyxnjpia
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
yuvarajkumar334
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
oaxefes
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
eoxhsaa
 
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
9gr6pty
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
KiriakiENikolaidou
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
z6osjkqvd
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
MastanaihnaiduYasam
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
eudsoh
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
nyvan3
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
NABLAS株式会社
 

Recently uploaded (20)

一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics May 2024
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCAModule 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
Module 1 ppt BIG DATA ANALYTICS_NOTES FOR MCA
 
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
一比一原版卡尔加里大学毕业证(uc毕业证)如何办理
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
 
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
 
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
一比一原版英属哥伦比亚大学毕业证(UBC毕业证书)学历如何办理
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
 
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
 

SQL: Creating and Altering Tables

  • 2. This is DDL DDL - Data Definition Language ● Creating and Altering the structure of the database. ● You are building the data dictionary!
  • 3. CREATE TABLE CREATE TABLE ARTISTS (ARTIST_ID INT, ARTIST_NAME VARCHAR(60), ARTIST_DOB DATE, POSTER_IN_STOCK BOOLEAN);
  • 4. Don’t Forget Data Types! CHAR DATE TIMESTAMP VARCHAR TIME BOOLEAN NUMERIC REAL DECIMAL DOUBLE INT PRECISION SMALLINT FLOAT
  • 5. User Defined (Data) Types CREATE TYPE SALARY AS NUMERIC(8,2) FINAL; CREATE TABLE EMPLOYEES (EMPLOYEE_ID INTEGER, EMPLOYEE_SALARY SALARY);
  • 6. Default Values CREATE TABLE ARTISTS (ARTIST_ID INT, ARTIST_NAME VARCHAR(60), PLACE_OF_BIRTH VARCHAR(60) DEFAULT ‘Unknown’);
  • 7. ALTER TABLE ALTER TABLE ARTISTS ADD COLUMN ARTIST_DOB DATE;
  • 8. ALTER COLUMN ALTER TABLE ARTISTS ALTER COLUMN PLACE_OF_BIRTH SET DEFAULT ‘Unknown’; ALTER TABLE ARTISTS ALTER COLUMN PLACE_OF_BIRTH DROP DEFAULT;
  • 9. DROP COLUMN ALTER TABLE ARTISTS DROP COLUMN PLACE_OF_BIRTH CASCADE;
  • 10. DROP TABLE DROP TABLE ARTISTS CASCADE; Not the Same as: TRUNCATE TABLE ARTISTS; Or DELETE * FROM ARTISTS;
  • 11. Required or Optional? CREATE TABLE CD_ARTISTS (ARTIST_ID INT NOT NULL, ARTIST_NAME VARCHAR(60) NOT NULL, PLACE_OF_BIRTH VARCHAR(60));
  • 12. Unique Constraints CREATE TABLE CD_INVENTORY (ARTIST_NAME VARCHAR(40), CD_NAME VARCHAR(60), COPYRIGHT INT, CONSTRAINT UN_ARTIST_CD UNIQUE (ARTIST_NAME, CD_NAME));
  • 13. Primary Keys CREATE TABLE CD_ARTISTS (ARTIST_ID INT, ARTIST_NAME VARCHAR(60), AGENCY_ID INT, CONSTRAINT PK_ARTIST_ID PRIMARY_KEY (ARTIST_ID, ARTIST_NAME);
  • 14. Foreign Keys CREATE TABLE CD_TITLES (CD_TITLE_ID INT, CD_TITLE VARCHAR(60), PUBLISHER_ID INT, FK_PUBLISHER_ID FOREIGN KEY (PUBLISHER_ID) REFERENCES CD_PUBLISHERS (PUBLISHER_ID));
  • 15. Column Constraints CREATE TABLE CD_TITLES (CD_TITLE INT, CD_TITLE VARCHAR(60) NOT NULL, IN_STOCK INT NOT NULL, CONSTRAINT CK_IN_STOCK (IN_STOCK > 0 AND IN_STOCK < 30));