MYSQL 簡單的建庫作業碼

來源:互聯網
上載者:User

標籤:刪除表   into   username   select   退出   ble   insert   har   刪除資料庫   

一、查詢所有資料庫

代碼:show databases;

成功後如:

二、建立一個資料庫

代碼:create database test3;

成功後如:

三、串連資料庫

代碼:use test3;

成功後如:

 

四、建立庫表

代碼:create table test{

id int not null primary key auto_increment,

name varchar(30) not null

};

成功後顯示:

 

 五、顯示表結構

代碼:desc test;

成功後顯示:

六、添加表內容

代碼:insert into test (`name`)values(‘test‘);

成功後顯示:

七、查詢表內容

代碼:select * from test;

成功後顯示:

八、修改表內容

代碼:update test set name = ‘test2‘;

成功後顯示:

九、刪除表內容

代碼:delete from test;

成功後顯示:

十、添加表欄位

代碼:alter table test add password varchar(30) not null;

成功後顯示:

十一、修改表欄位名

代碼:alter table test change name username varchar(50) not null;

成功後顯示:

 

 十二、修改表欄位類型

代碼:alter table test modify username char(30) not null;

成功後顯示:

十三、刪除表欄位

代碼:alter table test drop username;

成功後顯示:

十四、刪除資料庫表

代碼:drop table test;

成功後顯示:

十五、刪除資料庫

代碼:drop databases test3;

成功後顯示:

十六:關閉資料庫

代碼:exit;

 成功後退出命令列關閉。

 

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.