MySQL基礎文法

來源:互聯網
上載者:User

標籤:primary   mod   加一列   odi   alter   注意   dex   after   with   

 


增加一列到某列名後
alter table table_name add column_name int after column_name;

改變列名稱
alter table table_name change old_column_name new_column_name int;

修改類型
alter table table_name modify column_name float;

刪除列
alter table table_name drop column_name;

修改表名
alter table old_table_name rename new_table;

表結構的刪除
drop table table_name(注意外鍵的情況) with check option


添加主鍵
alter table table_name add primary key(COLUMN1,COLUMN2);

刪除主鍵
alter table table_name drop primary key;

添加約束
alter table table_name add unique(COLUMN_name);

刪除約束
alter table table_name drop index column_name;

 

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.