What does DDL mean?
# DDL--DATA DEFINITION LANGUAGE
# ---------- Database -----------------
# Create a database
Create database day19;
# Create a database encoded as utf8
Create database day191 CHARSET UTF8;
# Show All Database names
Show databases;
# Viewing database creation Information
Show create database day191;
Show create database day19;
Show create database ex01;
# Deleting a specified database
Drop database day191;
# View the database in use
Select database ();
# Select a database
USE day19;
# View the database in use
Select database ();
# Show all tables in the database
Show tables;
# ---------- Table --------------
# Create a table and add fields
Create table abc (
Aid int primary key,
Aname VARCHAR (20) not null unique,
Aage int null );
Create table abcd (
Did int primary key,
Dname VARCHAR (20 ),
Ddate DATE
);
# Display table structure
DESC abc;
DESC abcd;
# Deleting a table abcd
Drop table abcd;
# Show All Tables
Show tables;
# Modify a table-Add a column
Alter table abc
ADD holobby VARCHAR (24) null default '0 ';
# Display table structure
DESC abc;
# Modify a table-delete a column
Alter table abc
DROP holobby;
# Display table structure
DESC abc;
# Modifying the data types and constraints of a column
Alter table abc
MODIFY aage VARCHAR (20 );
DESC abc;
# Modifying Field Names
Alter table abc
CHANGE aage age DOUBLE (3, 2) not null default 0;
DESC abc;
# Modifying table names
Rename table abc TO bbc;
DESC bbc;
Rename table bbc to abc;
DESC abc;