Oracle基本操作

本文介绍了SQL中创建视图的基本语法及实例,并详细展示了如何创建用户、分配权限、创建表空间等数据库管理操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

SQL CREATE VIEW 语法

 

CREATE OR REPLACE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
 

例:

 

CREATE OR REPLACE VIEW  TO_LDPS AS
  select TO_NUMBER(CONCAT(ID,'0')) AS ID, PSJB,BZ,TO_CHAR(CHUZHIGONGZUO_ID) as TYPE_ID,'chuzhigongzuo' as TYPE from TO_CHUZHIGONGZUO_LDPS
  union 
  select TO_NUMBER(CONCAT(ID,'1')) AS ID, PSJB,BZ,TO_CHAR(DAJICHULI_ID) as TYPE_ID,'dajichuli' as TYPE  from TO_DAJICHULI_LDPS 
  

 

 

 

 

增加一个用户的SQL

 

 

 

  -- Create the user 
create user IBS2USERZH
  identified by IBS2USERZH
  default tablespace IBSZH
  temporary tablespace TEMP
  profile DEFAULT;
-- Grant/Revoke role privileges 
grant connect to IBS2USERZH;
grant dba to IBS2USERZH;
grant resource to IBS2USERZH;
-- Grant/Revoke system privileges 
grant unlimited tablespace to IBS2USERZH;

 

 

增加一个数据库的服务命名

文件D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora    

 

plsql字符串函数

http://hi.baidu.com/yzcp558/blog/item/230b0def368f2d3eadafd551.html

 

for update

 

创建表空间

/*分为四步 */
/*第1步:创建临时表空间  */
create temporary tablespace user_temp  
tempfile 'D:\oracle\oradata\Oracle9i\user_temp.dbf' 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第2步:创建数据表空间  */
create tablespace user_data  
logging  
datafile 'D:\oracle\oradata\Oracle9i\user_data.dbf' 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第3步:创建用户并指定表空间  */
create user username identified by password  
default tablespace user_data  
temporary tablespace user_temp;  
 
/*第4步:给用户授予权限  */
grant connect,resource,dba to username;

 下面是一个例子:

 

/*分为四步 */
/*第1步:创建临时表空间  tempfile要是orcl的目录才有权限*/
create temporary tablespace user_temp  
tempfile 'D:\app\Administrator\oradata\orcl\user_temp.dbf' 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第2步:创建数据表空间  */
create tablespace EMP_TASK  
logging  
datafile 'D:\app\Administrator\oradata\orcl\EMP_TASK.dbf' 
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第3步:创建用户并指定表空间  */
create user empTask identified by 123456  
default tablespace EMP_TASK  
temporary tablespace user_temp;  
 
/*第4步:给用户授予权限  */
grant connect,resource,dba to empTask;
 

 创建J2CMS

/*第2步:创建数据表空间  */  
create tablespace J2CMS    
logging    
datafile 'D:\app\Administrator\oradata\orcl\J2CMS.dbf'   
size 50m    
autoextend on    
next 50m maxsize 20480m    
extent management local;    
   
/*第3步:创建用户并指定表空间  */  
create user j2cms identified by password    
default tablespace J2CMS    
temporary tablespace user_temp;    
   
/*第4步:给用户授予权限  */  
grant connect,resource to j2cms;  

 

删除表空间

drop tablespace tbspaceName  INCLUDING CONTENTS;

删除用户

drop user USERNAME cascade;

 修改用户密码  (SYSDBA身份登陆)

 

SQL> alter user user01 identified by password;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值