mysql base tables and database operations _

1. Database operations

create database database name; # create a general way 

create database database name default charset utf8; # database encoding format utf8 

Show Databases; # see all the data 

drop database database name; # delete the database 

use the database name; enter the data #

2. The operation table

show tables; # View all the tables 

the Create  the Table T1 ( 
    the above mentioned id int , # Column name Data type 
    name char ( 10 ), # Column Name Data Type 
); # Create a table 

the Create  the Table T1 ( 
the above mentioned id int , name char ( 10 ) 
) default charset = utf8; # Create utf8 encoding format 

Create  table T1 ( 
ID int , 
name char ( 10 ) 
) Engine = InnoDB default charset =utf8; # Create utf8 Encoding format, and support transactional, atomic operations.

  (1) Create a table

    

Create  Table T1 ( 
    Column name Type null ; #NULL represents empty 
    Column name Type Not  null ; #NULL that they can not be empty 
    Column name Type Not  null aoto_increment Primary  Key ; #aoto_increment and implemented with increment primary key 
) Engine = InnoDB default charset = UTF8; 

aoto_increment: represents a self-energizing 
Primary  Key : represents a constraint (not repeatable and can not be empty); Find the acceleration

 

  (2) Empty Table

the Delete  from table name; Empty Table # 
# After emptying, continues to be inserted before the continuation of the self-energizing did not empty the 

TRUNCATE  the Table table name; 
after # emptied, continue to increment from zero insertion

  (3) Delete table

drop  the Table table name; # delete table

 

3. The operation of the data

Inserting data:
  INSERT  INTO T1 (ID, name) values ( . 1 , ' WDC ' ); 

View Data: 
  SELECT  *  from T1;

 

Guess you like

Origin www.cnblogs.com/wangdianchao/p/11414472.html