1.SELECT语句 sql="select * from 数据表 where 字段名=字段值 orderby字段名[desc]/[asc]" sql="select*from数据表where字段名like'%字段值%' " sql="select top 10 * from数据表where字段名=字段值 " sql="select*from数据表where字段名in('值1','值2','值3')" sql="select*from数据表where字段名between值1and值2"
2.UPDATE
sql="update 数据表 set 字段名=字段值 where条件表达式" sql="update数据表 set 字段1=值1,字段2=值2……字段n=值n where条件表达式"
3.DELETE
sql="delete from 数据表 where 条件表达式" sql="delete from数据表"(将数据表所有记录删除)
4.INSERT INTO sql="insert into 数据表(字段1,字段2,字段3…) values(值1,值2,值3…)" sql="insert into 目标数据表 select * from 源数据表" (把源数据表的记录添加到目标数据表)
5.数据记录统计函数: AVG(字段名)得出一个表格栏平均值 COUNT(*|字段名)对数据行数的统计或对某一栏有值的数据行数统计 MAX(字段名)取得一个表格栏最大的值 MIN(字段名)取得一个表格栏最小的值 SUM(字段名)把数据栏的值相加
6.CREATE TABLE
CREATE TABLE table-name (column-name column-type, column-name column-type,… PRIMARY KEY ( primary-key-column(s) ), [ FOREIGN KEY ( foreign-key column ) REFERENCES linked-table-name [ ON DELETE CASCADE | NO ACTION ] ] [ CHECK (条件) ] );
7.ALTER ALTER TABLE table-name MODIFY column-name column-type [ MODIFY column-name column-type … ];
ALTER TABLE table-name DROP CONSTRAINT constrain-name
ALTER TABLE table-name DROP COLUMN column-name
DROP TABLE table-name; 8.TRANSACTION BEGIN TRANSACTION transaction-name; ROLLBACK TRANSACTION transaction-name
9.GROUP BY/ HAVING
SELECT * FROM table-name [GROUP BY 列名序列[HAVING 组条件表达式]]
10.join
SELECT column-a, column-b……, FROM table-a, table-b WHERE table-a.attribute= table-b.attribute,……
SELECT * FROM table-a LEFT JOIN table-b ON table-a.attribute=table-b.attribute
THE OTHERS TRUNCATE TABLE: This command removes all of the rows from the table, but the table structure remains intact
SP_RENAME old-name, new-name
NOT NULL/UNIQUE |