sql文法,sql

來源:互聯網
上載者:User

sql文法,sql

SQL 指結構化查詢語言 (SQL)
下面是一個名為 “Persons” 的表:id自增,不用管

基礎的sql語句包括增、刪、改、查。
增:INSERT INTO 語句用於向表格中插入新的行。
INSERT INTO 表名稱 VALUES (值1, 值2,….)
也可以指定所要插入資料的列:
INSERT INTO table_name (列1, 列2,…) VALUES (值1, 值2,….)
例如:insert into persons values ( ‘J’,’yc’,’cn’,’qingdao’)
insert into persons(address,city) values (‘cn’,’beijing’)

刪:DELETE 語句用於刪除表中的行。
DELETE FROM 表名稱 WHERE 列名稱 = 值
delete from persons where city=’beijing’
刪除所有行
DELETE * FROM table_name

改:UPDATE 表名稱 SET 列名稱 = 新值 WHERE 列名稱 = 某值
update persons set address=’usa’ where city=’beijing’
更新某一行中的若干列
update persons set address=’usa’,lastname=’J’ where city=’beijing’

查:SELECT 列名稱 FROM 表名稱
select address from persons
從表中選取所有的列
select * from persons

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.