|
基本查询:
带条件的查询: - SELECT* FROM [table] WHERE [column] = [value]
复制代码
子查询: - SELECTa, b, c FROM a WHERE a IN (SELECT d FROM b)
复制代码
外连接查询: - SELECTa.a, a.b, a.c, b.c, b.d, b.f FROM a LEFT OUTER JOIN b ON a.a = b.c
复制代码
视图查询: - SELECT* FROM (SELECT a, b, c FROM a) T WHERE t.a > 1
复制代码
普通更新: - UPDATE[table] SET [column] = [value]
复制代码
关联表更新: - UPDATEA SET A1 = B1, A2 = B2, A3 = B3 FROM A, B WHERE A.ID = B.ID
复制代码
删除数据:
删除主表中已经在副表中没有的信息: - DELETE FROM table1 WHERE NOT EXISTS (SELECT * FROM table2WHERE table1.field1 = table2.field1)
复制代码
事务处理: 开始事务:
提交事务:
回滚事务:
结束事务:提交或回滚事务都将结束事务
创建数据库和表: - CREATEDATABASE database_name; CREATE TABLE table_name (column1 datatype, column2datatype, ...)
复制代码
插入数据: - INSERTINTO table_name (column1, column2, ...) VALUES (value1, value2, ...)
复制代码
删除表:
|
|