mysql 建立表

來源:互聯網
上載者:User

標籤:建立表   mys   com   char   orm   tin   rom   mysql   har   

1.刪除表 drop table  table_name;                  //table_name 表名

 

2.建立表,當標記某個屬性為主鍵的時候,已經建立主鍵索引

create table  student_info(
  id int not null auto_increment primary key comment ‘主鍵id‘,
  name varchar(20) null comment ‘姓名‘,
  
unique id(id asc) //建立主鍵唯一索引
  

);

mysql 索引的分類   顯示表的索引  

 show index from table;

 

normal  

   建立方式

index(column   desc|asc)   #index 索引別名   column 欄位名

   特點:普通索引

unique |full text  

  建立方式

 unique index(column desc|asc)

  特點:unique   要求唯一   full text  耗時耗空間

 

3.時間戳記格式

create table student(  id int not null primary key,        createTime timetamp  #時間戳記格式 預設為0000-00-00  00:00:00格式的時間);

4. 整型

  tinyint  一個位元組

  smallint  2個位元組

  int  4個位元組

  bigint 8個位元組   

 

5. char 和varchar  mysql5之後存的是字元   varchar的最大長度 六萬五千

 

mysql 建立表

聯繫我們

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