SQL學習筆記

2021-09-28 21:58:06 字數 1091 閱讀 4789

sql (structured query language)結構化查詢語言,是一種資料庫查詢和程式語言,用於訪問資料以及查詢、更新和管理關係資料庫系統。同時也是資料庫指令碼檔案的副檔名。sql作為結構化查詢語言,也是資料庫查詢和程式計語言,用於訪問資料以及查詢、更新和管理關係資料庫系統。也是資料庫指令碼檔案的副檔名。其次,sql是訪問和處理資料庫的標準的計算機語言。

sql可對資料庫執行查詢,更新,刪除,修改等操作。

用法: select 列 from 表名稱(select * from 表名稱)

作用: 查詢 列 來自 表名稱

例項:"table"表:id

性名性別

1何程龍男2

張斌濤男

select 姓名 from

table

;

結果:姓名

何程龍張斌濤

select

*from

table

;

星號(*):是選取所有列的快捷方式
結果:id

性名性別

1何程龍男2

張斌濤男

用法: select 列 from 表名稱 where 列

運算子值

功能: 查詢 列 滿足 列

運算子值 來自 表名稱

運算子包括:=,>,<,!=(不等於),>=,<=。

例項:

select

*from

table

where 姓名=

'何程龍'

;

結果:id

性名性別

1何程龍

select id from

table

where 姓名=

'張斌濤'

;

結果:id

2

以上

SQL 學習筆記 ( )

sql 語法特點 1 每個語句以 結束,中間用 包含,間隔。2 對變數和常量等需要用 包含。3 關鍵字大寫,變數名首大寫字母用表名表徵,然後用小寫表徵屬性 基本語句 desc 表名 檢視表詳細屬性 建表 create table 表名 屬性名 型別 約束 主鍵 primary key 如果是域為主鍵...

sql學習筆記

declare rc int declare stattime datetime declare endtime datetime select stattime 2008 06 22 00 00 00.000 select endtime 2008 06 22 01 00 00.000 while...

SQL學習筆記

一 資料庫的建立與刪除 create database demo drop database demo 二 表的定義與更改 1 表的定義 建立乙個學生情況表student create table student st class char 8 st no char 10 not null,st n...