mysql基本用法
資料庫操作
進入
mysql -u root -p
退出
\q exit quit
查看資料庫
show databases;
洗掉資料庫
drop database 資料庫名;
創建資料庫
create database 資料庫名;
查看資料庫的創建資訊
show create database 資料庫名
修改資料庫字符編碼
alter database teacher charset=gbk;
資料庫表操作
增(創建資料庫表)
create table (if not exists)表名(欄位1,欄位2…)
刪(洗掉資料庫表)
drop table (if exists) 資料庫名
改
修改表名
alter table 資料庫名 rename to 新資料庫名;
修改表的欄位
修改欄位型別(改)
alter table 表名 modify 欄位名 型別;
修改欄位名和型別(改)
alter table 表名 change 原欄位名 新欄位名 型別;
洗掉欄位(刪)
alter table 表名 drop 欄位名;
增加欄位(增)
alter table 表名 add 欄位名 型別(after 某欄位 / first)
查
查看已有的資料庫表
show tables;
查看表的創建資訊
show create table 表名;
desc 表名;
表中資料的操作
增(插入資料)
insert into 表名 (欄位1,欄位2…) values(資料1,資料2…);
insert into 表名 values(資料1,資料2…)
insert into teacher values(資料1,資料2…),(資料1,資料2…);
刪(洗掉資料)
delete from 表名 where 條件;
清空表:
delete from 表名; 遍歷清空,保留原id位置
truncate table 表名; 直接清空,毫無保留
改(更新資料)
update 表名 set 要改成的內容 where 改的位置(條件);
如果不給定位置,將改變該表中所有對應欄位的資料
查(查詢資料)
select * from 表名;
select 指定欄位 from 表名;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/1497.html
標籤:其他
上一篇:資料網站
下一篇:Jmeter基本操作-3
