數(shù)據(jù)庫學(xué)習(xí)01

(1)select語句

select * from website

select name from website

select name country? from website

(2)在表中一個列可能包含多個重復(fù)值,有時候希望列出不同(distinct)的值

select distinct country from websites

(3)where子句用于提取那些滿足制定標準的記錄

select * from Websites where country = ‘CN’;

select * from websites where id= 1;

SQL使用單引號來引用文本值,文本字段使用單引號,數(shù)字字段不使用

(4)如果在第一個條件第二個條件都成立,則and運算符顯示一條記錄,只有一個成立則是OR

select * from Websites where country = ‘CN’ and alexa >50;

select * from Websites where country = ‘USA’ or country = ‘CN’;

select * from Websites where alexa >15 and (country = ‘CN’ or country = ‘USA’);

(5)order by 關(guān)鍵字用于對結(jié)果集按照一個列或者多個列進行排序,默認升序,降序desc

select * from Websites order by alexa;

select* from Websites order by alexa DESC;

select *from Websites order by country, alexa;

(6)insert into用于向表中插入新記錄

假如像websites表中插入一個新行

insert into websites (name, url, alexa,country) values(‘百度’,’https://www.baidu.com/’,’4’,’CN’);

在指定列插入數(shù)據(jù)

insert into Websites (name,url, country)values (‘stackoverflow’,’http://stackoverflow.com/’,’IND’);

(7)update用于更新表中存在記錄

update Websites set alexa = ‘5000’,country = ‘USA’ where name=‘菜鳥教程’;

(8)用于刪除表中的行

delect from Websites where name= ‘百度’ and country=‘CN’;

不刪除表情況下刪除所有行

delect from Websites或 delect * from Websites

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • (1)select top 子句用于規(guī)定要返回的記錄數(shù)目 從Websites 表中選取頭兩條記錄 select *...
    LP_ProgramLife閱讀 419評論 0 0
  • 首先要知道我接下來要說的數(shù)據(jù)庫是關(guān)系型數(shù)據(jù)庫。我們直觀來看,一個數(shù)據(jù)庫可由多張表構(gòu)成,每張表有不重復(fù)的名稱(表名)...
    LP_ProgramLife閱讀 299評論 0 0
  • 創(chuàng)建表 語法 create table 表名(列+類型,列+類型); create table Websites ...
    尼爾君閱讀 464評論 0 1
  • 時隔一個半月,再次打開簡書寫作頁面。 最近這一個半月,一直在找工作,宣講會,面試的忙碌中度過的。 忙碌不能忘了學(xué)習(xí)...
    月出宛丘閱讀 541評論 4 2
  • 還有十來分鐘高鐵就要發(fā)車,而此時我在高鐵站門口等候安檢,排在我前面有二十來個旅客,此時我的心情是焦慮不安的,我擔(dān)心...
    皖塵閱讀 710評論 0 0

友情鏈接更多精彩內(nèi)容