CREATEUSER sales IDENTIFIED BY"Sxc1%sd27";GRANT DBA TO sales;
创建表area,并插入数据:
CREATETABLE area (
area_no CHAR(2)NOTNULLPRIMARYKEY,
area_name VARCHAR2(60),
DHQ VARCHAR2(20)DEFAULT'ShenZhen'NOTNULL);INSERTINTO area VALUES('01','华东','Shanghai');INSERTINTO area VALUES('02','华西','Chengdu');INSERTINTO area VALUES('03','华南','Guangzhou');INSERTINTO area VALUES('04','华北','Beijing');INSERTINTO area VALUES('05','华中','Wuhan');COMMIT;
查询area表的数据:
SELECT area_name FROM area;SELECT area_no, area_name FROM area;SELECT*FROM area;SELECT*FROM area WHERE area_name ='华东';SELECT*FROM area ORDERBY dhq;SELECT*FROM area ORDERBY dhq DESC;
SELECT*FROM branches;SELECT branches.branch_name, branches.address FROM branches INNERJOIN area ON branches.area_no = area.area_no;SELECT branches.branch_name, branches.address FROM branches RIGHTJOIN area ON branches.area_no = area.area_no;SELECT branches.branch_name, branches.address FROM branches FULLJOIN area ON branches.area_no = area.area_no;
描述area表的结构:
DESC area;
修改area表的数据:
INSERTINTO area(area_no, area_name, dhq)VALUES('06','东北','Dalian');COMMIT;UPDATE area SET dhq='Haerbin'WHERE area_no='06';COMMIT;UPDATE area SET dhq='Haerbin';COMMIT;DELETEFROM area WHERE area_no='06';COMMIT;DELETEFROM area;COMMIT;