SlideShare a Scribd company logo
5
Most read
6
Most read
7
Most read
© 2013 1keydata.com All Rights Reserved
SQL Tutorial
Table Management
Add, Remove, and Truncate Tables
Database Basics
Database
Tables
Columns
Rows
© 2013 1keydata.com All Rights Reserved
In a relational database, data is stored in tables. A table
consists of columns and rows.
CREATE TABLE
© 2013 1keydata.com All Rights Reserved
The first step to store data in a database is to add a table. To
do this, we use the CREATE TABLE command in SQL.
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2"
... )
The syntax for CREATE TABLE is:
CREATE TABLE
© 2013 1keydata.com All Rights Reserved
For example, the command below,
CREATE TABLE ALL_USERS
(LAST_NAME char(20),
FIRST_NAME char(20));
results in the creation of a table ALL_USERS with two
columns: LAST_NAME and FIRST_NAME, both 20
characters long.
DROP TABLE
© 2013 1keydata.com All Rights Reserved
One also needs to be able to remove tables from a database,
otherwise database management becomes very difficult. SQL
uses the DROP TABLE command to accomplish this.
The syntax for removing a table is:
DROP TABLE "table_name“;
To drop the ALL_USERS table we previously created, we use
the following SQL:
DROP TABLE ALL_USERS;
TRUNCATE TABLE
© 2013 1keydata.com All Rights Reserved
To remove all data but keep the table structure, SQL uses the
TRUNCATE TABLE command.
The syntax for TRUNCATE TABLE is:
TRUNCATE TABLE "table_name“;
To truncate the ALL_USERS table we previously created, we
use the following SQL:
TRUNCATE TABLE ALL_USERS;
1Keydata SQL Tutorial
http://www.1keydata.com/sql/sql.html
© 2013 1keydata.com All Rights Reserved

More Related Content

What's hot (20)

PPT
SQL Tutorial - Basic Commands
1keydata
 
PPT
Oracle Architecture
Neeraj Singh
 
PPT
Sql views
arshid045
 
PDF
Oracle SQL Basics
Dhananjay Goel
 
PPTX
Introduction to database & sql
zahid6
 
PPTX
History of MySQL
KentAnderson43
 
PDF
Consultas básicas en sql server
Rodrigo Alfaro Pinto
 
PPT
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
PDF
[APJ] Common Table Expressions (CTEs) in SQL
EDB
 
PPTX
DATABASE CONSTRAINTS
sunanditaAnand
 
PPTX
Oracle basic queries
PRAKHAR JHA
 
PPTX
User, roles and privileges
Yogiji Creations
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
PPTX
Oracle Database Introduction
Chhom Karath
 
PPT
SQL subquery
Vikas Gupta
 
PPTX
An Introduction To Oracle Database
Meysam Javadi
 
DOC
ETL QA
dillip kar
 
PPT
Single-Row Functions in orcale Data base
Salman Memon
 
PPTX
sql function(ppt)
Ankit Dubey
 
SQL Tutorial - Basic Commands
1keydata
 
Oracle Architecture
Neeraj Singh
 
Sql views
arshid045
 
Oracle SQL Basics
Dhananjay Goel
 
Introduction to database & sql
zahid6
 
History of MySQL
KentAnderson43
 
Consultas básicas en sql server
Rodrigo Alfaro Pinto
 
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
[APJ] Common Table Expressions (CTEs) in SQL
EDB
 
DATABASE CONSTRAINTS
sunanditaAnand
 
Oracle basic queries
PRAKHAR JHA
 
User, roles and privileges
Yogiji Creations
 
SQL - DML and DDL Commands
Shrija Madhu
 
Oracle Database Introduction
Chhom Karath
 
SQL subquery
Vikas Gupta
 
An Introduction To Oracle Database
Meysam Javadi
 
ETL QA
dillip kar
 
Single-Row Functions in orcale Data base
Salman Memon
 
sql function(ppt)
Ankit Dubey
 

Viewers also liked (20)

PPTX
SQL Basics
Hammad Rasheed
 
PPT
Sql ppt
Anuja Lad
 
PPTX
Data Manipulation Language
Jas Singh Bhasin
 
PDF
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PDF
Sql delete, truncate, drop statements
Vivek Singh
 
PDF
Part 15 triggerr
Denny Yahya
 
PPT
SQL Tutorial - Table Constraints
1keydata
 
DOC
Sql queries with answers
vijaybusu
 
PDF
Oracle Date Functions
Vigilant Technologies
 
PDF
SQL JOIN Explained Visually
Vincent Chan Yuen Mun
 
PDF
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
PDF
Sql insert statement
Vivek Singh
 
PPTX
6. triggers
Amrit Kaur
 
PDF
Sql create table statement
Vivek Singh
 
PPTX
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
PDF
Sql wksht-7
Mukesh Tekwani
 
PPT
Sql presentation 1 by chandan
Linux international training Center
 
SQL Basics
Hammad Rasheed
 
Sql ppt
Anuja Lad
 
Data Manipulation Language
Jas Singh Bhasin
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Sql delete, truncate, drop statements
Vivek Singh
 
Part 15 triggerr
Denny Yahya
 
SQL Tutorial - Table Constraints
1keydata
 
Sql queries with answers
vijaybusu
 
Oracle Date Functions
Vigilant Technologies
 
SQL JOIN Explained Visually
Vincent Chan Yuen Mun
 
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
Sql insert statement
Vivek Singh
 
6. triggers
Amrit Kaur
 
Sql create table statement
Vivek Singh
 
SAP HANA - Manually to insert_data_table
Yasmin Ashraf
 
Sql wksht-7
Mukesh Tekwani
 
Sql presentation 1 by chandan
Linux international training Center
 
Ad

Similar to SQL Tutorial - How To Create, Drop, and Truncate Table (20)

DOC
Oracle sql material
prathap kumar
 
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
PPTX
Introduction to database and sql fir beginers
reshmi30
 
PPTX
SQL commands in database managemant systems
pmselvaraj
 
DOCX
Sq lite
Revuru Bharadwaja
 
PPTX
Database Languages power point presentation
AshokRachapalli1
 
PPTX
Lab2 ddl commands
Balqees Al.Mubarak
 
PPTX
SQL.pptx for the begineers and good know
PavithSingh
 
PPT
Mysql
TSUBHASHRI
 
PPTX
MySQL Essential Training
HudaRaghibKadhim
 
PPTX
Unit 2 Chap 4 SQL DDL.pptx
PetroJoe
 
PPTX
lovely
love0323
 
PDF
SQL Database Performance Tuning for Developers
BRIJESH KUMAR
 
PPT
Presentation1
ahsan-1252
 
PPTX
Creating database using sql commands
Belle Wx
 
DOCX
SQL Tutorial for BCA-2
Raj vardhan
 
PPTX
Database COMPLETE
Abrar ali
 
PPTX
SQL.pptx
MarilouJamis1
 
PPTX
SQL
Rajesh-QA
 
Oracle sql material
prathap kumar
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Introduction to database and sql fir beginers
reshmi30
 
SQL commands in database managemant systems
pmselvaraj
 
Database Languages power point presentation
AshokRachapalli1
 
Lab2 ddl commands
Balqees Al.Mubarak
 
SQL.pptx for the begineers and good know
PavithSingh
 
Mysql
TSUBHASHRI
 
MySQL Essential Training
HudaRaghibKadhim
 
Unit 2 Chap 4 SQL DDL.pptx
PetroJoe
 
lovely
love0323
 
SQL Database Performance Tuning for Developers
BRIJESH KUMAR
 
Presentation1
ahsan-1252
 
Creating database using sql commands
Belle Wx
 
SQL Tutorial for BCA-2
Raj vardhan
 
Database COMPLETE
Abrar ali
 
SQL.pptx
MarilouJamis1
 
Ad

Recently uploaded (20)

PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PDF
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PPTX
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PPTX
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
PPTX
SHREYAS25 INTERN-I,II,III PPT (1).pptx pre
swapnilherage
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PPTX
05_Jelle Baats_Tekst.pptx_AI_Barometer_Release_Event
FinTech Belgium
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
PDF
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
1750162332_Snapshot-of-Indias-oil-Gas-data-May-2025.pdf
sandeep718278
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
BinarySearchTree in datastructures in detail
kichokuttu
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
04_Tamás Marton_Intuitech .pptx_AI_Barometer_2025
FinTech Belgium
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
SHREYAS25 INTERN-I,II,III PPT (1).pptx pre
swapnilherage
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
05_Jelle Baats_Tekst.pptx_AI_Barometer_Release_Event
FinTech Belgium
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
Research Methodology Overview Introduction
ayeshagul29594
 
The European Business Wallet: Why It Matters and How It Powers the EUDI Ecosy...
Lal Chandran
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
What Is Data Integration and Transformation?
subhashenia
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 

SQL Tutorial - How To Create, Drop, and Truncate Table

  • 1. © 2013 1keydata.com All Rights Reserved SQL Tutorial Table Management Add, Remove, and Truncate Tables
  • 2. Database Basics Database Tables Columns Rows © 2013 1keydata.com All Rights Reserved In a relational database, data is stored in tables. A table consists of columns and rows.
  • 3. CREATE TABLE © 2013 1keydata.com All Rights Reserved The first step to store data in a database is to add a table. To do this, we use the CREATE TABLE command in SQL. CREATE TABLE "table_name" ("column 1" "data_type_for_column_1", "column 2" "data_type_for_column_2" ... ) The syntax for CREATE TABLE is:
  • 4. CREATE TABLE © 2013 1keydata.com All Rights Reserved For example, the command below, CREATE TABLE ALL_USERS (LAST_NAME char(20), FIRST_NAME char(20)); results in the creation of a table ALL_USERS with two columns: LAST_NAME and FIRST_NAME, both 20 characters long.
  • 5. DROP TABLE © 2013 1keydata.com All Rights Reserved One also needs to be able to remove tables from a database, otherwise database management becomes very difficult. SQL uses the DROP TABLE command to accomplish this. The syntax for removing a table is: DROP TABLE "table_name“; To drop the ALL_USERS table we previously created, we use the following SQL: DROP TABLE ALL_USERS;
  • 6. TRUNCATE TABLE © 2013 1keydata.com All Rights Reserved To remove all data but keep the table structure, SQL uses the TRUNCATE TABLE command. The syntax for TRUNCATE TABLE is: TRUNCATE TABLE "table_name“; To truncate the ALL_USERS table we previously created, we use the following SQL: TRUNCATE TABLE ALL_USERS;