国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

sql server 入門語句總結

2024-08-31 00:56:31
字體:
來源:轉載
供稿:網友

對于數據庫來說多多少少要掌握一點,首先基本的SQL語句要了解。下面來總結一些入門級別的SQL語句。

create相關

•show database; 顯示出現有的數據庫
•use database_x; 現在要使用數據庫database_x
•create table coffee (id int(5) not null,coffee_name varchar(25)); 創建一張表,包含id和coffee_name兩個字段
•alter table coffee add taste varchar(10); 增加新的一列
•insert into coffee (id,coffee_name,taste,rank) value ("1","BlueMountain",“well”,“5”); 插入數據
•show columns from coffee; 查看表結構
•show create table coffee; 查看表信息,包括建表語句
•alter table student rename ss; 改變表名
•alter table ss drop mark; 刪除表ss中mark列
select語句

•select * from coffee where; 查詢出id=1的所有信息
•select coffee_name from coffee where; 查詢出id=2的coffee name
•select * from club where id between "1" and "3"; 查詢出id=1到3的條目
•select * from club where or; 查詢出id=1和id=3這兩個條目
•select club_name from club where mark>50; 查詢出mark大于50的club
•select club_name from club where mark not between 48 and 50; 查詢mark不在48與50之間的club
•select * from club where id in("1","3","4"); 查詢id=1,3,4的條目
•select * from club where id not in("1","3","4");
•select * from club where name like "M%r"; 通配符%表示任意長度的字符(可以是0,漢字為兩個字符)
•select * from club where name like "M_r"; _表示單個字符
•select * from club where id in("1","3","4") and mark>50; 多重查詢
•select * from club order by mark desc; 按照mark降序排列(desc:降序,usc:升序)
數量查詢相關

•select count(*) from club; 查詢club中有多少條記錄
•select count(distinct mark) from club; 不同分數的有多少條記錄
•select sum(mark) from club; 積分總和
•select avg(mark) from club; 平均積分
•select max(mark) from club; 最高積分
•select min(mark) from club; 最低積分
update語句

•update club set mark=mark-8 where; id=1的俱樂部積分罰8分
delete語句

•delete from club where; 刪除id=001的俱樂部信息
以上語句都是SQL語句增刪改查最基本的部分,屬于入門級別,一定要掌握。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武强县| 晋中市| 常熟市| 庄河市| 建阳市| 池州市| 土默特左旗| 博兴县| 九江市| 攀枝花市| 嘉祥县| 大冶市| 白沙| 雷山县| 洛南县| 安国市| 德保县| 榆社县| 紫金县| 贡嘎县| 广汉市| 泽库县| 武平县| 灵寿县| 昌邑市| 高阳县| 张掖市| 高州市| 三原县| 平远县| 萝北县| 晋江市| 康乐县| 达拉特旗| 扶绥县| 平乡县| 库车县| 临泉县| 衡南县| 大余县| 宁海县|