---
title: "Oracle常用语句"
author: "传说中的旅人"
date: "2011-08-01T10:35:42Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-08-01T10:36:50Z"
id: 1137083
url: "https://lengend.iteye.com/blog/1137083"
---

1.查看和修改Oracle服务器端字符集：

1)   查看服务器端字符集：

方法一：

select * from v$nls\_parameters;

select * from nls\_database\_parameters;

select * from sys.props$;

2) 修改服务器端字符集(用sys用户)：

首先执行：update props$ set value$ = 'WE8ISO8859P1' where name ='NLS\_CHARACTERSET';

update props$ set value$ = 'china' where name ='NLS\_LANGUAGE';

提交（commit），然后，重新启动数据库；

3）用客户端工具（PL/SQL DEVELOP or PB etc.）查询数据库，若显示乱码，先查询出数据库端的字符集，然后，从注册表中修改NLS\_LANG字段的值，可能为AMERICAN\_AMERICA.WE8ISO8859P1或者SIMPLIFIED CHINESE\_CHINA.ZHS16GBK或者NA等。

方法二：

alter system enable restricted session;

alter database ORCL character set ZHS16GBK;

alter database ORCL national character set ZHS16GBK;

 

2.创建Oracle表空间：

-- oracle 安装在windows 系统 建立表空间语句

create tablespace test\_service

datafile 'E:\\oracle\\oradata\\ora92\\test\_service01.dbf' size 100M REUSE

LOGGING

ONLINE

PERMANENT

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M

--oracle 安装在aix系统 建立表空间语句

create tablespace test\_service

datafile '/dev/rdata01' size 100M reuse

LOGGING

ONLINE

PERMANENT

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M

 

3.删除用户及用户的所有对象：

drop user USER cascade;

 

4.创建用户，及赋予权限：

-- Create the user 

create user tcw

identified by "123456"

default tablespace USERS

temporary tablespace TEMP;

 

-- Grant/Revoke role privileges 

grant connect to tcw;

grant dba to tcw;

 

-- Grant/Revoke system privileges 

grant select any table to tcw;