mysql圖形化工具基本操作
阿新 • • 發佈:2020-08-26
- `int` 整數 - `varchar(len)` 字串 - `tinyint(1)`布林值
二.設定欄位的特殊標識
- `PK`(`Primary Key`) --- 主鍵、唯一標識 - `NN`(`Not Null`) --- 值不允許為空 - `UQ`(`Unique`) --- 值唯一 - `AI`(`Auto Increment`) --- 值自動增長
三.基本操作
1.通過 * 把 users 表中的所有的資料查詢出來
select * from users
2.
-- 多列之間,使用英文逗號進行分隔
select username, password from users
3.向資料表中插入新的資料行
insert into users (username, password) values ('mz', '123456') //注意:新的資料需要加上引號,否則會報錯
4.改表中的資料
update users set password=888888, status=1 where id=4 //update 表名稱 SET 列名稱 = 新值 whree 列名稱 = 某值
//多個被更新的列之間, 使用英文的逗號進行分隔
//where 後面跟著的是更新的條件
5.用於刪除表中的行 (忘記提供更新的 where 條件,這樣會導致整張表的資料都被更新,一定要慎重)
delete FROM users where id=4 //DELETE FROM 表名稱 WHERE 列名稱 = 值
6.WHERE字句
-- 查詢 id 為 1 的所有使用者 select* from users where id=1 -- 查詢 id 大於 2 的所有使用者 select * from users where id>2 --查詢 username 不等於 admin 的所有使用者 select * from users where username<>'zs'