My SQL 命令列知識點總結(一)

2021-09-12 08:30:53 字數 1885 閱讀 4194

今日再一次的翻看了資料庫的書,想到了自己剛剛入門的時候的麻煩,特來寫一篇入門的命令列總結。對自己是乙個總結,當然了希望可以幫到哪怕乙個人。

今日著重介紹搜尋型別的命令列。

my sql 資料庫    >各類子資料庫    >每個庫還有表

當我們開啟資料庫的時候,可以先檢視所有的

show databases;

如果有自己要使用的表,可以直接use table;(table指的是某一張表)

1、展示該錶的所有內容

select * from table;

2、展示某一列的內容

select  id from table;

3、展示多列的內容

select id,name from table;

4、展示指定行數的內容

select id,name from table limit 5;

6、指定多列內容且是從第幾行開始

select id,name from limit 5 offset 2;

上述的內容的意思是從第二行(my sql 的第一行為0)開始的五行內容

7、展示類別的內容(如每個年齡僅僅展示乙個,個人感覺應運場景就是展示多少類別)order

select distinct *** from table;

8、公升序,降序

select id ,age from table order by age;         --公升序(預設公升序)

select id ,age from table  order by age desc;   -- 降序

select id ,age from table order by age , id desc;   --整體的趨勢為按年齡降序,年齡相同的情況下降序

9、過濾語句

select id ,age from table where age >18;      --要求年齡大於18

select id ,age from table where between 18 and 60;  -- 要求年齡大於18 以及小於60

10、高階過濾

select id,age from table where age >18 and age <60;  --與上訴的between 效果一樣

select id age from table where age >18 or id <20;    --可以理解為或的意思

11萬用字元的運用(其實可以理解為模糊搜尋)

select id,age from table where name like '%w%';   -- 檢視名字中帶有 w 的名字

select id,age from table where name like 'w%';

select id,age from table where name like '%w';

12、下劃線的「_」萬用字元

select id,age from table where name like '__w' -- 檢視名字中第三個字元為 w 的名字;

--因為前看有右兩個下劃線「_」

Java命令列簡單知識點

圖形化介面能做的事情命令列都能做,圖形化介面對命令列進行封裝處理的產品 dos命令列 先進入windows命令列工具 1.要想進入e盤,需在c users xiangfei 後面加e 後按enter進入 2.開啟e盤目錄用dir命令列 3.要想進入e盤的指定檔案資料夾需要cd命令列 cd chang...

MySQL 命令列總結

參看所有資料庫 show databases 使用資料庫 use databasename 參看當前資料庫中的所有表 show tables 檢視表的結構 describe tablename 檢視建表的sql語句 show create table tablename 檢視資料庫版本 select...

MySQL知識點 總結

1 truncate和delete trop之間有什麼區別?truncate table 在功能上與不帶 where 子句的 delete 語句相同 二者均刪除表中的全部行。但 truncate table 比 delete 速度快,且使用的系統和事務日誌資源少。delete 語句每次刪除一行,並在...