在黑窗口中导出所写的语句:
spool e:/aa.sql;(在开始的时候执行,e:/aa.sql是保存文件的路径和名称)
spool off;(在想要结束的时候使用)mysql
显示用户:show user;sql
更改用户:conn 用户名/密码@服务名;
若是是以管理员的身份登陆的话能够这样:
conn sys/aa as sysdba;数据库
解锁:
alter user scott account unlock;ide
修改密码:
alter user scott identified by 新密码;sqlserver
将删除的权利赋予某个角色:
grant delete on tablename to 角色;server
显示错误:
show error;rem
打开Oracle的运行环境:
开始-->运行-->cmd-->sqlpluscmd
添加惟一约束:it
在建立表的时候直接添加table
create table table_name(
column1 datatype null/not null,
……
constraint unique_name unique(column1……))
在建立以后添加约束:
alter table table_name add constraint unique_name unique(column1,column2……)
表中添加一列: alter table tablename add (column datatype [default value][null/not null],….);
修改字段的语法:alter table tablename modify (column datatype [default value][null/not null],….);
删除字段的语法:alter table tablename drop (column);
删除sequence :drop sequence SEQ_NAME;
导入导出数据库:
exp AAA/AAA@130.251.101.4/orcl file=e:\AAA0904.dmp owner=(AAA);
imp AAA/AAA@130.251.101.92/orcl full=y file=e:\AAA(init).dmp ignore=y;
主键是拼接:
<selectKey resultClass="String" keyProperty="id">
SELECT 'CG-'|| to_char(current_timestamp,'yyyyMMdd')||'-'||lpad(to_char(SEQ_NAME.nextval),3,'0') FROM DUAL
</selectKey>
建立序列:
create sequence SEQ_NAME
increment by 1
start with 1
maxvalue 999
minvalue 1
cycle
cache 20
order;
数据相加减:SELECT isnull(A,0)-isnull(B,0) AS 结果 FROM 表 --sqlserver语法SELECT nvl(A,0)-nvl(B,0) AS 结果 FROM 表 --Oracle语法SELECT ifnull(A,0)-ifnull(B,0) AS 结果 FROM 表 --mysql语法 NVL( total , 0) + NVL( money, 0)---Oracle 或者 DB2 ISNULL( total , 0) + ISNULL( money, 0)-- SQL Server IFNULL( total , 0) + IFNULL( money, 0)--MySQL 或者 SQLite