?
1、select
?? ?select 用于從表中提取數(shù)據(jù)
?? ??? ?語法:
?? ??? ?select 列名稱 from 表名稱
?? ??? ?select *? from 表名稱
?? ??? ?例如:
?? ??? ?select lastName, firstName from Persons? 表示從Persons數(shù)據(jù)庫表中提取lastName和firstName列的內(nèi)容
?? ??? ?select * from Persons?? 表示提取Persons數(shù)據(jù)庫表中所有列的內(nèi)容
?? ??? ?
?? ??? ?語法:
?? ??? ?select distinct? 列名稱 from 表名稱
?? ??? ?在表中,可能會(huì)包含重復(fù)值。用distinct可以返回唯一不同的值
?? ??? ?例如:
?? ??? ?select? Company from Orders?? 表示提取Orders數(shù)據(jù)庫表中Company列里所有不同的值
?? ??? ?
?? ??? ?語法:
?? ??? ?select 列名稱 from 表名稱 where 列 運(yùn)算符 值
?? ??? ??? ?運(yùn)算符
?? ??? ??? ?操作符??????????? 描述
?? ??? ??? ?=?? ??? ??? ??? ?? 等于
?? ??? ??? ?<> 或者!=?? ??? ?? 不等于
?? ??? ??? ?>?? ??? ??? ??? ?? 大于
?? ??? ??? ?<???????????????? 小于
?? ??? ??? ?>=??????????????? 大于等于
?? ??? ??? ?<=??????????????? 小于等于
?? ??? ??? ?between?????????? 在某個(gè)范圍內(nèi)
?? ??? ??? ?link????????????? 搜索某種模式
?? ??? ?例如:
?? ??? ?select * from? Persons where City ='beijing'?? 表示選取Persons數(shù)據(jù)庫表中,居住城市在beijing的所有列
?? ??? ?注意:
?? ??? ?在例子中條件值周圍使用的是單引號(hào),表示是文本值。如果是數(shù)值,則不需要使用引號(hào)。
?? ??? ?
?? ??? ?語法:
?? ??? ?and 和or 運(yùn)算符
?? ??? ?and和or可在where子語句中把兩個(gè)或多個(gè)條件結(jié)合起來。
?? ??? ?
?? ??? ?語法:
?? ??? ?order by 語句
?? ??? ?order by 語句用于根據(jù)指定列對(duì)結(jié)果集進(jìn)行排序
?? ??? ?order by 語句默認(rèn)按照升序?qū)τ涗涍M(jìn)行排序
?? ??? ?若希望按照降序?qū)τ涗涍M(jìn)行排序,可以使用desc關(guān)鍵字
?? ??? ?select 列名稱 from 表名稱 order by 列名稱,列名稱 desc關(guān)鍵字
?? ??? ?
?? ??? ?語法:
?? ??? ?select into 語句
?? ??? ?select into 語句從一個(gè)表中選取數(shù)據(jù),然后把數(shù)據(jù)插入另一個(gè)表中
?? ??? ?select into 語句常用于創(chuàng)建表備份復(fù)件或者用于對(duì)記錄進(jìn)行存檔
?? ??? ?select * from into 新表名稱 from 舊表名稱
?? ??? ?
?? ??? ?
?? ?2、insert語句
?? ??? ?語法:
?? ??? ?Insert into 用于向表中插入新的行, 添加到表末尾
?? ??? ?insert into 表名稱 values (值1,值2……)
?? ??? ?指定要插入數(shù)據(jù)的列
?? ??? ?insert into 表名稱 (列1,列2……) values(值1,值2……)
?? ??? ?
?? ?3、update語句
?? ??? ?語法:
?? ??? ?update 表名稱 set 列名稱 = 新值 where 列名稱 =某值
?? ??? ?用于修改表格中的數(shù)據(jù)
?? ??? ?
?? ?4、delete語句
?? ??? ?語法:
?? ??? ?delete from 表名稱 where 列名稱 =值
?? ??? ?delete語句用于刪除表中的行
?? ??? ?在不刪除表的情況下,刪除所有行。
?? ??? ?delete from 表名稱
?? ??? ?delete * from 表名稱
?? ?5、 create語句
?? ??? ?語法:
?? ??? ?create database 用于創(chuàng)建數(shù)據(jù)庫
?? ??? ?create database 數(shù)據(jù)庫名稱
?? ??? ?
?? ??? ?語法:
?? ??? ?創(chuàng)建數(shù)據(jù)庫中的表
?? ??? ?create table 表名稱
?? ??? ?(
?? ??? ? 列名稱1 數(shù)據(jù)類型,
?? ??? ? 列名稱2 數(shù)據(jù)類型,
?? ??? ? 列名稱3 數(shù)據(jù)類型,
?? ??? ? ……
?? ??? ?)
?? ????
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
