MySQL command on-line Baidu comes out is a lot of, this is just to tidy up more than usual instructions.
Baidu Library In this article can refer to http://wenku.baidu.com/view/b5e83a27ccbff121dd368357.html
Common types of data
The MySQL Terminator is ";" ends.
1. Show the host database
show databases;
2. Deleting a database
Drop database dbName;
3. Create a Database
drop database [if not EXISTS] dbName;
The parentheses section is optional, and the database is determined to be created if it does not exist.
4. Switch, use the specified database
Use DbName;
5. Display all table objects currently using the database
Show tables;
6. Display the underlying structure describe (DESC)
DESC TableName;
Use of 7.ALTER table
Show Table T1 first. Table T1 is created using the following methods:
CREATE TABLE T1 (a integer,b CHAR (10));
Rename the table T1 to T2:
ALTER TABLE T1 RENAME T2;
Change column A from interger to tinyint not NULL (the name remains the same), change column B from char (10) to char (20), and rename column B to column C:
ALTER TABLE T2 MODIFY A TINYINT not NULL, change b C CHAR (20);
Add a new timestamp column with the name D:
ALTER TABLE T2 ADD D TIMESTAMP;
To add an index to column D and column A:
ALTER TABLE T2 Add index (d), add index (a);
Delete Column C:
ALTER TABLE T2 DROP COLUMN C;
Add a new auto_increment integer column with the name C:
ALTER TABLE T2 ADD C INT UNSIGNED not NULL auto_increment,
ADD PRIMARY KEY (c);
Note that we indexed the C (as primary KEY) because the auto_increment column must be indexed. At the same time we define C as not NULL because the primary key column cannot be null
MySQL Common commands