每天學習一點MySQL系列(2)— use、show、describe、help、select、distinct、limit

1)use

--選擇數據庫
use database

2)show

show databases;
show tables;
--更多關於show的命令
help show;

3)describe

describe table;
--等價於
show columns from table;

4)help

5)select

--檢索單個列
select column1 from table;
--檢索多個列:使用逗號隔開
select column1, column2, column3 from table;
--檢索所有列
select * from table;

6)SQL語句不區分大小寫。

7)SQL的所有空格都被忽略。

8)distinct

distinct關鍵字應用於所有的列而不僅僅是前置它的列!

--僅僅從列表1中返回不同的值,重複值只返回一個
select distinct column from table;

9)limit

注意:limit 1, 1檢索出來的是第二行而不是第一行。

--返回不多於5行的值
select * from table limit 5;
--返回從第3行開始的5行數據
select * from table limit 3,5;
--等價於
select * from table limit 5 offset 3;

10)完全限定的表達

select table.column1 from database.table;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章