MySQL建立資料庫和表的Demo

來源:互聯網
上載者:User

標籤:

Demo:

建立資料庫的文法 
1、基本文法 
create database tour character set gbk; 

use tour; 
無主鍵自增長的 
create table EMB_T_Employee 

   emb_c_operatorID     int not null, 
   emb_c_empCode        varchar(255) not null, 
   emb_c_gender         int not null, 
   emb_c_email          varchar(255) not null, 
   emb_c_empMPhone      varchar(255) not null, 
   emb_c_empTel         varchar(255), 
   emb_c_empZipCode     varchar(50), 
   emb_c_empPID         varchar(50), 
   emb_c_empBirthDate   datetime, 
   emb_c_empAddress     varchar(512), 
   emb_c_regDate        datetime not null, 
   emb_c_displayOrder   int not null, 
   primary key (emb_c_operatorID) 
)engine=INNODB default charset=gbk; 
有主鍵自增長不控制主鍵的起點 
create table emb_t_dictBusType 

   emb_c_busTypeID      int not null auto_increment, 
   emb_c_busTypeEnName  varchar(255) not null, 
   emb_c_busTypeZhName  varchar(255) not null, 
   primary key(emb_c_busTypeID)   
)engine=INNODB  default charset=gbk; 
有主鍵自增長控制主鍵的起點 
create table emb_t_dictBusType 

   emb_c_busTypeID      int not null auto_increment, 
   emb_c_busTypeEnName  varchar(255) not null, 
   emb_c_busTypeZhName  varchar(255) not null, 
   primary key(emb_c_busTypeID)   
)engine=INNODB auto_increment=1001 default charset=gbk; 
2、查看當前所有的資料 
show databases; 
3、查看當前資料庫的所有表 
show tables; 
4、查看錶結構 
desc emb_t_dictBusType ; 
5、查看字元集 
show variables like ‘collation_%‘; 
show variables like ‘character_set_%‘; 
6、修改資料庫的字元集 
alter database tour character set utf-8; 

 

著作權出處:http://www.blogjava.net/sxyx2008/

 

MySQL建立資料庫和表的Demo

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.