Create dB & table in MySQL

Source: Internet
Author: User

 

1. Database

   1: show databases;

   2:  

   3: use DB_NAME;

   4:  

   5: create database DB_NAME; 

   6:  

 

2. Table

   1: show tables;

   2:  

3: Create Table table_name; // List 2

   4:  

   5: describe TABLE_NAME ; 

   6:  

   7: select * from TABLE_NAME ;

   8:  

   9: insert into TABLE_NAME  values (’xxx’,’xxx’,’xxx’,’xxx’);

  10:  

  11: delete from TABLE_NAME ;

  12:  

1: -- create database 'abc _ db '; 2: 3: Drop table if exists 'abc _ table '; 4: Create Table 'abc _ table '( 5: 'id' bigint (20) not null auto_increment, -- primary key 6: 'topic 'varchar (32) not null, 7: 'group _ id' varchar (64) not null, 8: 'md5' varchar (4000) default null 9: Primary Key ('id ') 10:) engine = InnoDB default charset = utf8;

For more information about engine = InnoDB, see here:

Http://dev.mysql.com/doc/refman/5.1/zh/storage-engines.html

 

3. Index

   1: show index from TABLE_NAME ;

   2:  

   3: show keys from TABLE_NAME ;

   4:  

   5: create index INDEX_NAME on TABLE_NAME (COLUMN1, COLUMN3,…); 

   6:  

   7: drop index INDEX_NAME on TABLE_NAME;

   8:  

   9: alter table TABLE_NAME add index INDEX_NAME (COLUMN1, COLUMN3,…); 

  10:  

  11: alter table TABLE_NAME drop index INDEX_NAME;

  12:  

 

Refer:

Http://www.chinaz.com/program/2010/0119/104365.shtml

Http://hi.baidu.com/pibuchou/blog/item/268adc33a36ab294a8018e75.html

Http://happyman-bruce.blogbus.com/logs/1740464.html

 

 

4. Others

Show processlist;

Show grants for user_name;

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.