linux資料庫常用指令

來源:互聯網
上載者:User

標籤:定義   條件   href   com   分享圖片   target   min   info   sql   

linux資料庫環境搭建好之後,我們就可以建立資料庫了,如果不是

  

很瞭解linux資料庫環境搭建的話,可以到看看我上一篇文章linux資料庫環境搭建

首先我們來建立一個資料庫:使用指令sqlite3 mysql

 

指令1:建立表格

create table [表名] [資料類型(約束條件)];
create table mysql(id integer primary key autoincrement,name char not NULL,number char not NUll);

我們使用命令.table查看一下剛才建立好的表格,可以看到,mysql表格建立完成了

 

指令2:插入資料到表格中

insert into [表名] values [自訂的資料類型];
insert into mysql values(1,‘xiaoming‘,‘123456‘);

 

指令3:查看錶格中的資料

selecet * from [表名];
select * from mysql;

 

指令4:更新表格中的資料

update [表名] set [要修改的內容] where [表格中的位置];
update mysql set number=‘654321‘ where id=1;

 

 

指令5:刪除表格中的資料,在這之前我們使用命令insert into mysql values(2,‘xiaohong‘,‘456789‘);先加入一個資料 

delete from [表名] where [表格中的位置];
delete from mysql where id=1;

 

指令6:更改表格的名字

alter table [表名] rename to [新的表名];
alter table mysql rename to mysql2;

 

指令7:刪除表格

drop table [表名];
drop table mysql2;

今天先講這麼多,以後有空再補上其他的操作指令。

linux資料庫常用指令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.