常用的MYSQL 命令

來源:互聯網
上載者:User

標籤:

例1:建立一個名為xhkdb的資料庫
   mysql> create database xhkdb;

 

例2:顯示資料庫

命令:show databases (注意:最後有個s)
mysql> show databases;

 

例3:刪除資料庫

例如:刪除名為 xhkdb的資料庫
mysql> drop database xhkdb;

 

例3:使用資料庫

例如:如果xhkdb資料庫存在,嘗試存取它:
   mysql> use xhkdb;
工具提示:Database changed

 

--

例1:建立表

 

例如,建立一個名為MyClass的表,

欄位名 數字類型 資料寬度 是否為空白 是否主鍵 自動增加 預設值
id int 4 primary key auto_increment  
name char 20      
sex int 4     0
degree double 16      


mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default ‘0‘,
> degree double(16,2));

 

例2:刪除表

例如:刪除表名為 MyClass 的表
   mysql> drop table MyClass;

 

例3:插入資料

mysql> insert into MyClass values(1,‘Tom‘,96.45),(2,‘Joan‘,82.99), (2,‘Wang‘, 96.59);

 

例4:更新資料

文法:update 表名 set 欄位=新值,… where 條件
   mysql> update MyClass set name=‘Mary‘ where id=1;

常用的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.