標籤:定義 條件 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資料庫常用指令