Oracle基础语句
1、
连接数据库
connect uuu/ooo
connect
sys/ok as sysdba
2、
创建表空间
create tablespace stu(表空间名
) datafile
‘
e:\stu.dbf
’
size 100m autoextend on next 5m maxsize 500m;
3、
删除表空间
drop tablespace stu including contents and datafiles;
4、
创建用户
create user uuu(用户名
) identified by uuu(
密码
) default tablespace stu(
表空间名
);
5、
修改用户密码
alter user uuu identified by ppp(x新密码
);
6、
删除用户
drop user uuu casoade;
7、
锁定用户
alter user uuu account lock;
8、
解锁用户
alter user uuu account unlock;
9、
授予用户权限
grant all to uuu(用户名
);
//授权所有权限
grant create session to uuu;
//授权连接数据库权限
grant connect,resource to uuu;
10、
查看用户权限
select * from user_sys_privs;
11、
删除用户权限
revoke all from uuu;
12、
创建表
create table STUDENT
(
STUNO VARCHAR2(20) not null,
STUNAME VARCHAR2(50),
BIRTHDAY DATE,
XUELI VARCHAR2(10),
SEX INTEGER
)
tablespace STUDB
;
13、
删除表
drop table student;
14、
创建主键约束
alter table student
add constraint
pk_stuno
primary key(stuNo);
创建check
约束
alter table
student
add constraint
ck_name
check (
saly>100
);
15、
创建外键约束
alter table STUDENT add constraint FK_SEX foreign key (SEX) refe
相关文档:
1. 复制表结构及其数据:
create table table_name_new as select * from table_name_old
2. 只复制表结构:
create table table_name_new as select * from table_name_old where 1=2;
或者:
create table table_name_new like table_name_old
3. 只复制表数据:
如果两个表结构一样:
insert into table_name_ ......
The following are number examples for the to_char
function.
to_char
(1210.73,
'9999.9')
would return '1210.7'
to_char
(1210.73,
'9,999.99')
would return '1,210.73'
to_char
(1210.73,
'$9,999.00')
would return
'$1,210.73'
to_char
(21,
'000099')
would return '000021'
The foll ......
一. 死锁的检测
--查死锁的会话。
select A.sid, b.serial#,
decode(A.type,
'MR', 'Media Recovery',
'RT','Redo Thread',
'UN','User Name',
'TX', 'Transaction',
'TM', ' ......
1.使用sqlldr
2.首先建立相应的表
create table test(ip1 number, ip2 number, locate varchar2(512),country varchar2(60),province varchar2(60),city varchar2(60))
3.写控制文件 city.ctl
load data
infile 'c:\city.txt'
append into table test
--when country='中国'
fields terminated by ','
(
ip1,
ip ......
把数据从一个表复制到另一个表,插入新数据或替换掉老数据是每一个ORACLE DBA都会经常碰到的问题。在ORACLE9i以前的年代,我们要先查找是否存在老数据,如果有用UPDATE替换,否则用INSERT语句插入,其间少不了还有一些标记变量等等,繁琐的很。现在ORACLE9i专为这种情况提供了MERGE语句,使这一工作变得异常轻松,
MERGE语 ......