create DB & TABLE in Mysql

來源:互聯網
上載者:User

 

1. 資料庫

   1: show databases;

   2:  

   3: use DB_NAME;

   4:  

   5: create database DB_NAME; 

   6:  

 

2. 表

   1: show tables;

   2:  

   3: create table  TABLE_NAME ; //清單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, -- 主鍵 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;

關於ENGINE=InnoDB,請參看這裡:

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

 

3. 索引

   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:  

 

參考:

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. 其它

show processlist;

show grants for USER_NAME;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.