日期:2014-05-16  浏览次数:20372 次

Oralce常用操作命令

1.创建表空间
create tablespace 表空间名
default ‘filename’/path’服务器端路径’ [size integer [k | m]] [autoextend [off | on]];
size:制定文件的大小,autoextend:用来启动或禁用数据文件的自动扩展。

2.创建新用户
create user 用户名
identified by 密码
[default tablespace 表空间]
[temporary tablespace 临时表空间];

3.为用户授权
grant 权限 to 用户
grant 权限 on 表名 to 用户

4.修改用户密码
alter user 用户名
identified by 密码;

5.删除用户
drop user 用户名 casaed;

6.查看当前用户
show user

7.查看当前时间
select sysdate from dual;

8.查看当前用户下的所有表
select table_name from user_tables;

9.查看当前表的结构
desc 表名

10.修改上一条的内容
edit;

Oracle 数据库对象

1.同义词
?? a.创建同义词
??????? 私有同义词
????????? create [or replace] synonym 同义词名 for 对象名;
??????? 共有同义词
????????? create [or replace] public synonym 同义词名 for 对象名;
?? b.删除同义词
????????? drop synonym同义词名;

2.序列
?? a.创建序列
????? create sequence 序列名
???????? [start with integer]
???????? [increment by integer]
???????? [maxvalue integer | nomaxvalue]
???????? [minvalue?? integer | nominvalue]
???????? [cycle | nocycle]
???????? [cache integer | nocache];
?? b.访问序列
????? select 序列名.nextval from dual;
????? select 序列名.currval from dual;
?? c.根改序列
????? alter sequence 序列名
???????? [increment by integer]
???????? [maxvalue integer | nomaxvalue]
???????? [minvalue?? integer | nominvalue]
???????? [cycle | nocycle]
???????? [cache integer | nocache];
?? d.删除序列
????? drop sequence序列名;

Oracle 数据表管理(一)

1.创建表
?? create table 表名
(字段名1 类型,
?? 字段名2?? 类型…);
2.修改表命令
?? 更改现有列
?????? alter table 表名 modiey (column definition….);
?? 向表中添加新列

????? alter table 表名 add (column definition….);
?? 删除表中现有的列
????? alter table 表名 drop column 列名;
3.删除表中的记录而不删除表结构

????? truncate table 表名;
4.删除与表的所有内容

????? drop table 表名 cascade;
5.数据操作语言(DML)
?? SELECT
???? Select * | {[distinct] 字段名 | 表达式[列别名],…}
???? From 表明
???? [where 条件]
???? [order by 字段名];
??????????????? distinct:限制只返回不同的列
?? CTAS
???? Create table 新表名 as select 字段名 from 旧表名;
???? //拷贝旧表的结构和记录,不拷贝约束
?? INSERT
????? Insert into 表名 [(字段名)] values (值);
?? IIS
????? Insert into 表名1(字段名1) select 字段名2 from 表名2;
?????? //表结构已存在,从另一个表中复制记录
?? UPDATE
????? Update 表名
????? Set 字段名=新值
?????? [where 条件];
?? DELETE
????? Delete 表名
?????? [where 条件];

6.事务控制语言
COMMIT
??? Commit;//提交
SAVEPOINT
??? Savepoint 保存点;
ROLLBACK
??? Rollback or Rollback work;

7.数据控制语言