SQL Cheat Sheet Create Table - MD
SQL Cheat Sheet Create Table - MD
origin=www…
CREATE CREATE TABLE table_name (col1 CREATE TABLE statement is to create the CREATE TABLE employee ( employee_id
TABLE datatype optional keyword, col2 table. Each column in the table is char(2) PRIMARY KEY, first_name
datatype optional keyword,col3 specified with its name, data type and varchar(30) NOT NULL, mobile int);
datatype optional keyword,..., coln an optional keyword which could be
datatype optional keyword) PRIMARY KEY, NOT NULL, etc.,
ALTER ALTER TABLE table_name ADD COLUMN ALTER TABLE statement is used to add ALTER TABLE employee ADD COLUMN
TABLE - column_name_1 datatype....ADD the columns to a table. income bigint;
ADD COLUMN column_name_n datatype;
COLUMN
ALTER ALTER TABLE table_name ALTER COLUMN ALTER TABLE ALTER COLUMN statement ALTER TABLE employee ALTER COLUMN
TABLE - column_name_1 SET DATA TYPE is used to modify the data type of mobile SET DATA TYPE CHAR(20);
ALTER datatype; columns.
COLUMN
ALTER ALTER TABLE table_name DROP COLUMN ALTER TABLE DROP COLUMN statement is ALTER TABLE employee DROP COLUMN
TABLE - column_name_1 ; used to remove columns from a table. mobile ;
DROP
COLUMN
ALTER ALTER TABLE table_name RENAME ALTER TABLE RENAME COLUMN statement ALTER TABLE employee RENAME COLUMN
TABLE - COLUMN current_column_name TO is used to rename the columns in a first_name TO name ;
RENAME new_column_name; table.
COLUMN
TRUNCATE TRUNCATE TABLE table_name TRUNCATE TABLE statement is used to TRUNCATE TABLE employee IMMEDIATE ;
TABLE IMMEDIATE; delete all of the rows in a table. The
IMMEDIATE specifies to process the
statement immediately and that it
cannot be undone.
DROP DROP TABLE table_name ; Use the DROP TABLE statement to DROP TABLE employee ;
TABLE delete a table from a database. If you
delete a table that contains data, by
default the data will be deleted
alongside the table.
Author(s)
Himanshu Birla
Changelog
Date Version Changed by Change Description
https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DB0201EN-SkillsNetwork/labs/CheatSheet/SQL-Cheat-Sheet-Create-Table.md.html?origin=www.coursera.org 1/1