Mysql part1 --- (DDL) Statement, part1 --- ddl

Source: Internet
Author: User

Mysql part1 --- (DDL) Statement, part1 --- ddl

12:47:30

1. query the database under the current connection
Show databases;

2. Create a new database
Create database [if not exists] java03 [CHARSET UTF8];

// Create database java03;

3. delete a database
Drop database [if exists] JAVA03;

4. Set the sequence set

Alter database java03 character set utf8;

5. Access the java03 Database
USE java03;

6. display all tables of the current database
Show tables;

7. Create a table
Create table Name (
Column name 1 type,
Column name 2 type,
...
);

8. Print the table creation statement
Show create table name

// Show create table class;

9. view the table structure
DESC table name;

// Desc class;

10. delete a table
Drop table Name;

11. add columns
Alter table name ADD (column name 1, column name 2 ,...);

12. Modify the column name Type
Alter table name MODIFY column name type;

// Alter table student MODIFY classid char;
Change the type of the classid column in the student table to char.

 

 

 

13. Modify the column name
Alter table name CHANGE old column name new column name type;

// Alter table student CHANGE classid class char;
Change the name of the classid column in the student table to class.

 

14. Delete Columns
Alter table Name DROP column name;

// Alter table student DROP class;
Delete the class column in the student table

 

15. Modify the table name
Alter table old TABLE name RENAME new TABLE name;

// Alter table student RENAME s1;

Change the name of the student table to s1.

 

 

Related Article

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.