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.