mysql常用命令總結

來源:互聯網
上載者:User

標籤:操作   外鍵約束   命令   欄位   foreign   ref   str   tab   約束   

 一、約束操作
  • 增加主鍵約束
  • alter table 表名 add constraint 約束名 primary key(列名)
  • 增加外鍵約束
  • alter table 表名 add constraint 約束名 foreign key(列名) references 表名(列名);
  • 刪除主鍵約束
  • alter table 表名 drop primary key
  • 刪除外鍵約束
  • alter table 表名 drop foreign key 約束
二、欄位操作
  • 添加欄位
  • alter table 表名 add column 欄位名 資料類型
  • 刪除欄位
  • alter table 表名 drop column 列名;
  • 修改欄位
  • alter table 表名 change 舊列名 新列名 資料類型
三、表操作
  • 修改表名
  • alter table 舊錶名 rename to 新表名
  • 查看錶結構
  •  desc 表名

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.