Mysql基本操作

來源:互聯網
上載者:User

標籤:

顯示資料庫:show  databases;

使用資料庫(串連資料庫  切換資料庫):use+資料庫名稱;

顯示某一資料庫裡的表格:show tables;

建立資料庫:create database+資料庫名稱;

建立表格:

create table  student(

      id int(4) primary key auto_increment,

      name varchar(11)  NOT NULL comment "姓名",

      number varchar(11) NOT NULL comment "學號"

);

 

(動作表格內容資料)

查詢某表格裡所有資料:select * from 表格名稱;

                     // select name,number from 表格名稱;

 

向某表格裡插入一條資料:insert into 表格名稱 values(屬性值);

                      // insert into 表格名稱(name,number) values(‘sdf‘,‘sdfgh‘);

 

刪除某表格裡的某一條記錄:delete from 表名 where 屬性=某一值;

 

 

修改某表格裡的某一條記錄:update 表格名稱 set 屬性=某一值 where 屬性=某一值;

 

 

 

(動作表格屬性)

顯示表格結構屬性:   desc+表格名稱;

增加某表格的某屬性:alter table 表名 add 屬性名稱 資料類型等;

刪除某表格的某屬性:alter table 表名 drop 屬性名稱;

修改某表格的某屬性:alter table 表名  change 原來的屬性名稱  修改後的屬性名稱 資料類型;

 

資料類型:範圍按經驗而定

         datatime類型是個時間格式

         tinyint(4);代表某一個數字;

 

修改資料庫表格的名稱:rename table 原來的表名 to 現在的表名;

    查看修改是否成功:  show tables;

 

刪除資料庫表格:drop table 表名;

 

刪除資料庫:drop database 資料庫名;

 

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.