SlideShare a Scribd company logo
3
Most read
5
Most read
9
Most read
SQL CREATE and DROP
TABLE Statement
Database System 2
Angelo T. Retita
IT-Instructor
Objectives
• 1. Will able to understand in Creating Database Table.
• 2. Will able to determine the syntax in Creating Database Table.
• 3. Will able to understand in Deleting Database Table.
• 4. Will able to determine the syntax in Deleting Database Table.
SQL CREATE TABLE Statement
• The CREATE TABLE statement is used to create a new table in a
database.
SQL CREATE TABLE Syntax
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
The column parameters specify the
names of the columns of the table.
The datatype parameter specifies the type of data the
column can hold (e.g. varchar, integer, date, etc.).
Note:
To Specify the Database where you want your table
to be inserted. Use this Syntax once:
Use databaseName;
SQL CREATE TABLE Example
• The following example creates a table called "Persons" that contains five
columns: PersonID, LastName, FirstName, Address, and City:
The PersonID column is of type int and will hold an integer.
The LastName, FirstName, Address, and City columns are of type varchar and will hold characters, and the maximum
length for these fields is 255 characters.
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
Table “Persons”
• The empty "Persons" table will now look like this:
SQL DROP TABLE Statement
• The DROP TABLE statement is used to drop an existing table in a
database.
SQL DROP TABLE Syntax
DROP TABLE table_name;
Note: Be careful before dropping a table. Deleting
a table will result in loss of complete information
stored in the table!
SQL DROP TABLE Example
• The following SQL statement drops the existing table "Persons":
DROP TABLE Persons;
SQL TRUNCATE TABLE
• The TRUNCATE TABLE statement is used to delete the data inside a
table, but not the table itself.
Syntax
TRUNCATE TABLE table_name;
SQL TRUNCATE Example
• The following SQL statement TRUNCATE the existing records of
“tblGrades“ table:
TRUNCATE TABLE tblGrade;
tblGrade before
Create a query
Result:
Ad

Recommended

SQL Overview
SQL Overview
Stewart Rogers
 
introdution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Computer Science:Sql Set Operation
Computer Science:Sql Set Operation
St Mary's College,Thrissur,Kerala
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
SQL Constraints
SQL Constraints
Randy Riness @ South Puget Sound Community College
 
SQL Joins.pptx
SQL Joins.pptx
Ankit Rai
 
Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base
Salman Memon
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
Constraints In Sql
Constraints In Sql
Anurag
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
Using the set operators
Using the set operators
Syed Zaid Irshad
 
SQL Functions
SQL Functions
ammarbrohi
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joins
Deepthi Rachumallu
 
Joins in SQL
Joins in SQL
Vigneshwaran Sankaran
 
Triggers
Triggers
Pooja Dixit
 
View & index in SQL
View & index in SQL
Swapnali Pawar
 
Index in sql server
Index in sql server
Durgaprasad Yadav
 
SQL commands
SQL commands
GirdharRatne
 
Triggers in SQL | Edureka
Triggers in SQL | Edureka
Edureka!
 
Introduction to sql
Introduction to sql
VARSHAKUMARI49
 
Basic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
SQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Create table
Create table
Nitesh Singh
 
Oracle Database Sequence
Oracle Database Sequence
Eryk Budi Pratama
 
Sql tutorial
Sql tutorial
Rumman Ansari
 
4. plsql
4. plsql
Amrit Kaur
 
Aggregate function
Aggregate function
Rayhan Chowdhury
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
Raj vardhan
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 

More Related Content

What's hot (20)

Constraints In Sql
Constraints In Sql
Anurag
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
Using the set operators
Using the set operators
Syed Zaid Irshad
 
SQL Functions
SQL Functions
ammarbrohi
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joins
Deepthi Rachumallu
 
Joins in SQL
Joins in SQL
Vigneshwaran Sankaran
 
Triggers
Triggers
Pooja Dixit
 
View & index in SQL
View & index in SQL
Swapnali Pawar
 
Index in sql server
Index in sql server
Durgaprasad Yadav
 
SQL commands
SQL commands
GirdharRatne
 
Triggers in SQL | Edureka
Triggers in SQL | Edureka
Edureka!
 
Introduction to sql
Introduction to sql
VARSHAKUMARI49
 
Basic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
SQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Create table
Create table
Nitesh Singh
 
Oracle Database Sequence
Oracle Database Sequence
Eryk Budi Pratama
 
Sql tutorial
Sql tutorial
Rumman Ansari
 
4. plsql
4. plsql
Amrit Kaur
 
Aggregate function
Aggregate function
Rayhan Chowdhury
 

Similar to 1.2 sql create and drop table (20)

SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
Raj vardhan
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Lecture - MY-SQL/ SQL Commands - DDL.pptx
Lecture - MY-SQL/ SQL Commands - DDL.pptx
umershah0263
 
lab#1,2,3.pptx
lab#1,2,3.pptx
AkifaAbbas
 
RDBMS Lab02 creating tables (UIU)
RDBMS Lab02 creating tables (UIU)
Muhammad T Q Nafis
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
SQl data base management and design
SQl data base management and design
franckelsania20
 
Creating, altering and dropping tables
Creating, altering and dropping tables
punu_82
 
chapter 8 SQL.ppt
chapter 8 SQL.ppt
YitbarekMurche
 
SQL DDL
SQL DDL
Vikas Gupta
 
Database Management System 1
Database Management System 1
Swapnali Pawar
 
Sql
Sql
pratik201289
 
Sql basics
Sql basics
Aman Lalpuria
 
SQL. It education ppt for reference sql process coding
SQL. It education ppt for reference sql process coding
aditipandey498628
 
2..basic queries.pptx
2..basic queries.pptx
MalaikaRahatQurashi
 
SQL
SQL
Mohamed Essam
 
225523359001djcj4_DBMS_LAB_THEORY_DML.pdf
225523359001djcj4_DBMS_LAB_THEORY_DML.pdf
sahilurrahemankhan
 
Sql create table statement
Sql create table statement
Vivek Singh
 
Db1 lecture4
Db1 lecture4
Sherif Gad
 
SQL Tutorial for BCA-2
SQL Tutorial for BCA-2
Raj vardhan
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Lecture - MY-SQL/ SQL Commands - DDL.pptx
Lecture - MY-SQL/ SQL Commands - DDL.pptx
umershah0263
 
lab#1,2,3.pptx
lab#1,2,3.pptx
AkifaAbbas
 
RDBMS Lab02 creating tables (UIU)
RDBMS Lab02 creating tables (UIU)
Muhammad T Q Nafis
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
SQl data base management and design
SQl data base management and design
franckelsania20
 
Creating, altering and dropping tables
Creating, altering and dropping tables
punu_82
 
Database Management System 1
Database Management System 1
Swapnali Pawar
 
SQL. It education ppt for reference sql process coding
SQL. It education ppt for reference sql process coding
aditipandey498628
 
225523359001djcj4_DBMS_LAB_THEORY_DML.pdf
225523359001djcj4_DBMS_LAB_THEORY_DML.pdf
sahilurrahemankhan
 
Sql create table statement
Sql create table statement
Vivek Singh
 
Ad

More from MLG College of Learning, Inc (20)

PC111.Lesson2
PC111.Lesson2
MLG College of Learning, Inc
 
PC111.Lesson1
PC111.Lesson1
MLG College of Learning, Inc
 
PC111-lesson1.pptx
PC111-lesson1.pptx
MLG College of Learning, Inc
 
PC LEESOON 6.pptx
PC LEESOON 6.pptx
MLG College of Learning, Inc
 
PC 106 PPT-09.pptx
PC 106 PPT-09.pptx
MLG College of Learning, Inc
 
PC 106 PPT-07
PC 106 PPT-07
MLG College of Learning, Inc
 
PC 106 PPT-01
PC 106 PPT-01
MLG College of Learning, Inc
 
PC 106 PPT-06
PC 106 PPT-06
MLG College of Learning, Inc
 
PC 106 PPT-05
PC 106 PPT-05
MLG College of Learning, Inc
 
PC 106 Slide 04
PC 106 Slide 04
MLG College of Learning, Inc
 
PC 106 Slide no.02
PC 106 Slide no.02
MLG College of Learning, Inc
 
pc-106-slide-3
pc-106-slide-3
MLG College of Learning, Inc
 
PC 106 Slide 2
PC 106 Slide 2
MLG College of Learning, Inc
 
PC 106 Slide 1.pptx
PC 106 Slide 1.pptx
MLG College of Learning, Inc
 
Db2 characteristics of db ms
Db2 characteristics of db ms
MLG College of Learning, Inc
 
Db1 introduction
Db1 introduction
MLG College of Learning, Inc
 
Lesson 3.2
Lesson 3.2
MLG College of Learning, Inc
 
Lesson 3.1
Lesson 3.1
MLG College of Learning, Inc
 
Lesson 1.6
Lesson 1.6
MLG College of Learning, Inc
 
Lesson 3.2
Lesson 3.2
MLG College of Learning, Inc
 
Ad

Recently uploaded (20)

From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
grete1122g
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
NEW-IDM Crack with Internet Download Manager 6.42 Build 27 VERSION
grete1122g
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 

1.2 sql create and drop table

  • 1. SQL CREATE and DROP TABLE Statement Database System 2 Angelo T. Retita IT-Instructor
  • 2. Objectives • 1. Will able to understand in Creating Database Table. • 2. Will able to determine the syntax in Creating Database Table. • 3. Will able to understand in Deleting Database Table. • 4. Will able to determine the syntax in Deleting Database Table.
  • 3. SQL CREATE TABLE Statement • The CREATE TABLE statement is used to create a new table in a database.
  • 4. SQL CREATE TABLE Syntax CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... ); The column parameters specify the names of the columns of the table. The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer, date, etc.). Note: To Specify the Database where you want your table to be inserted. Use this Syntax once: Use databaseName;
  • 5. SQL CREATE TABLE Example • The following example creates a table called "Persons" that contains five columns: PersonID, LastName, FirstName, Address, and City: The PersonID column is of type int and will hold an integer. The LastName, FirstName, Address, and City columns are of type varchar and will hold characters, and the maximum length for these fields is 255 characters. CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) );
  • 6. Table “Persons” • The empty "Persons" table will now look like this:
  • 7. SQL DROP TABLE Statement • The DROP TABLE statement is used to drop an existing table in a database.
  • 8. SQL DROP TABLE Syntax DROP TABLE table_name; Note: Be careful before dropping a table. Deleting a table will result in loss of complete information stored in the table!
  • 9. SQL DROP TABLE Example • The following SQL statement drops the existing table "Persons": DROP TABLE Persons;
  • 10. SQL TRUNCATE TABLE • The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself. Syntax TRUNCATE TABLE table_name;
  • 11. SQL TRUNCATE Example • The following SQL statement TRUNCATE the existing records of “tblGrades“ table: TRUNCATE TABLE tblGrade; tblGrade before