What does DDL mean?

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.