创建数据库:
Create Database DBname;
删除数据库:
Drop Database DBname;
创建表:
根据已有表创建表:
CREATE TABLE NewPerson as select * FROM person;
修改表名:
RENAME person TO NEWPERSON;
删除新表:
DROP TABLE NEWPERSON;;
添加新列:
alter TABLE person add(AGE NUMBER(2));
删除新列;
alter TABLE person DROP COLUMN AGE;
更改列名:
ALTER TABLE NEWPERSON RENAME COLUMN personid TO id;
更改列的类型:
ALTER TABLE NEWPERSON MODIFY lastname VARCHAR(255);
简单的删除操作:
DELETE FROM DBIDENTIFIER WHERE SITENAME = 'TOBEYSERVER'
简单的插入操作:
INSERT INTO DBIDENTIFIER(ASSIGNMENTTIMESTAMP,DBIDENTIFIER,SITENAME)VALUES( to_date('2016-04-25 14:52:31', 'yyyy-mm-dd hh24:mi:ss'),8000000000,'TOBEYSREVER')
简单的修改操作:
UPDATE DBIDENTIFIER SET SITENAME = 'TOBEY' WHERE SITENAME = 'TOBEYSREVER';
简单的查询语句:
select * FROM DBIDENTIFIER WHERE SITENAME = 'TOBEYSERVER'
Like用法:
SELECT * FROM NEWPERSON WHERE lastname LIKE '%BEY';
Count用法:
SELECT count (ID) as abc FROM newperson;
SUM用法:
SELECT sum(ID) as abc FROM newperson;
AVG用法:
SELECT avg(ID) as abc FROM newperson;
最大用法:
SELECT max(ID) as abc FROM newperson;
最小用法:
SELECT min(ID) as abc FROM newperson;
A:左外连接(左连接):结果集几包括连接表的匹配行,也包括左连接表的所有行。
SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c;
B:right (outer) join:
右外连接(右连接):结果集既包括连接表的匹配连接行,也包括右连接表的所有行。
C:full/cross (outer) join:
全外连接:不仅包括符号连接表的匹配行,还包括两个连接表中的所有记录。
In用法:
select a,b,c from a where a IN (select d from b );