跟我一起學Mysql常用命令(三)
阿新 • • 發佈:2018-11-20
Mysql常用命令
select version();
查詢mysql伺服器的版本
show databases;
顯示當前資料庫
use 庫名;
開啟指定的庫
show tables;
展示當前資料庫的所有表
show tables from 庫名;
展示某個庫裡的所有表
show database();
展示當前使用的資料庫
create table stuinfo(
id int,
name varchar(20)
);
建立一張stuinfo表
desc stuinfo;
檢視stuinfo表結構
select * from stuinfo;
查詢stuinfo的所有資訊
insert into stuinfo (id,name) values(1,'job');
向stuinfo表插入id和name
update stuinfo set name='lilei' where id=1;
將stuinfo這張表id為1的名字更新為lilei
delete from stuinfo where id=1;
將stuinfo表中id為1的行刪除
MYSQL語法規範
- 不區分大小寫,建議關鍵字大寫,表名、列名小寫
- 每條命令最好用分號結尾 最好別用 ‘\g’
- 每條命令根據需要,可以縮排或換行
- 註釋
- 單行註釋:#註釋文字
- 單行註釋:-- 註釋文字
- 多行註釋:/* 註釋文字 */
上面說的都是怎麼操作 cmd 命令來進行對資料庫的操作,在這裡推薦兩款比較經典實用的MySQL圖形化客戶端軟體SQLyong(小海豚)、Navicat。以後還會持續~