1   1  /  1  页   跳转

ORACLE 数据库(一)

ORACLE 数据库(一)

用户命令部分

用户登陆
Connect;
查看当前用户
Show user;
查看所有用户
Select username from dba_users;
创建用户
Create user 'Name' identified by 'Password';
授BDA最高权限
Grant DBA to 'Name';
授所有普通权限
Grant connect,reource to 'Name';
授权登陆
Grant create session to 'Name';
授权建表
Grant create table BMW();
授权无限表空间
Grant create umlimited tablespace to 'Name';
授查询权限
Grant select on BMW to 'Name';
撤消查询权限
Revoke select on BMW to 'Name';
修改自己的密码(登陆自己的用户)
Alter user 'name' identified by 'password';
修改别人的密码(登陆超级用户)
Alter user 'name' identified by 'password';
不输入密码登陆(*只能登陆SYS用户)
Connect / as sysdba


数据库操作部分

建表
create table BMW(
2  SN number(10) constraint zph1 primary key,
3  Model varchar2(20) constraint zph2 not null,
4  Color varchar2(10) constraint zph3 references BMW(Color),
5  Barcode number(30) constraint zph4 unique,
6  Price number(7) constraint zph5 check(Price between 10 and 90));
添加字段
Alter table 'Apellation' add('fieldname'  'fieldtype');
删除字段
Alter table 'Apellation' drop column 'fieldname';
修改字段长度
Alter table 'Apellation' modify('fieldname'  'fieldtype');
修改字段类型
Alter table 'Apellation' modify('fieldname'  'fieldtype');
向表中插入一条记录(所有字段)
Insert into 'Apellation' values('data','data',data,);
向表中插入一条记录(部分字段)
Insert into 'Apellation'('fieldname') values('data');
修改表中一个字段
Updata 'Apellation' set 'fieldname'='xxx' where 'fieldname'='id';
删除表中所有记录
Delete from 'Apellation';
删除表的结构和记录
Drop table 'Apellation';
查看某个表所有记录
Select * from 'Apellation';
查看某个表指定记录
Select 'fieldname','fieldname' from 'Apellation';
查看别人的表的记录(在别人先授查表权情况下)
Select * from 'name'.'Apellation';
查看当前用户下所有表
Select * from tab;
查看表结构
desc 'Apellation';
控制不换行显示
Set linesize 'Parameter'
控制每页显示行数
Set pagesize 'Parameter'
升序排列显示
Select * from 'Apellation';
交互式插入记录
Insert into 'Apellation' values('&data','&data',&data,);
转义字符
set escape on
Insert into 'Apellation' values('data','data',da\&ta,);


特殊命令部分

清除屏幕
Clear screen
文件日志命令
Spool F:\zph.txt
Spool off
提交命令
Commit
回滚命令
Rollback
设置保存点
Savepoint 'zph1'
查当前日期格式
select * from nls_session_parameters;
更改日期格式
Alter session set nls_date_format='yyyy-mm-dd';
更改数字显示格式
Column barcode format 999999999999999999999999999999;
调整行宽
Set linesize 200
调整显示字数
Set pagesize 100
最后编辑2006-01-20 09:23:59
分享到:
gototop
 

上述很多操作是有现成的"按钮"的,但如果要输入代码,在什么地方输呢?
gototop
 
1   1  /  1  页   跳转
页面顶部
Powered by Discuz!NT