oracle建表空间建库

--李丹给的 建表空间和数据库的语句
--Create TableSpace
create tablespace cmcs_hb_test datafile 'E:\oracle\product\10.2.0\oradata\ORCL\cmcs_hb_test.DBF'
size 1000m
/*(autoextend on)*/
autoextend on
next 32m maxsize 2048m
extent management local;
-- Create the user
create user cmcs_gx
identified by "cmcs_gx"
default tablespace cmcs_gx
temporary tablespace TEMP
profile DEFAULT;

-- Grant/Revoke role privileges
grant connect to cmcs_gx;
grant resource to cmcs_gx;

-- Grant/Revoke system privileges
grant create database link to cmcs_gx;
grant create materialized view to cmcs_gx;
grant create procedure to cmcs_gx;
grant create public synonym to cmcs_gx;
grant create role to cmcs_gx;
grant create sequence to cmcs_gx;
grant create synonym to cmcs_gx;
grant create table to cmcs_gx;
grant create trigger to cmcs_gx;
grant create type to cmcs_gx;
grant create view to cmcs_gx;
grant unlimited tablespace to cmcs_gx;

--导出数据库中所有表:
exp tas_gx/[email protected]/orcl file='d:\a.dmp' full=y;

--导出数据库中指定的某几张表
exp cmbbcd/[email protected]:1521/BCDL file=D:\BCDL_HB.dmp tables=(cmcs3_payment_list ,cmcs3_transfer_bill)

--导入表,要删除本地的 table , view ,sequence,然后导入
imp bcdl_hb/[email protected]/orcl file=c:/bcdl_hb.dmp full=y

--oracle sys 密码
sys change_on_install
system manager

--如下是修改sys 和 system 的密码
conn / as sysdba
alter user system identified by 'manager';
alter user sys identified by  'change_on_install';

--oracle查看索引信息
user_indexes:     系统视图存放是索引的名称以及该索引是否是唯一索引等信息。
user_ind_column:  系统视图存放的是索引名称,对应的表和列等

--查看索引个数和类别:
SQL> select * from user_indexes where table='表名'

查看索引被索引的字段:
SQL> select * from user_ind_columns where index_name=upper('&index_name');

--我们可以通过类似下面的语句来查看一个表的索引的基本情况:
select user_ind_columns.index_name,user_ind_columns.column_name,
user_ind_columns.column_position,user_indexes.uniqueness
from user_ind_columns,user_indexes
where user_ind_columns.index_name = user_indexes.index_name
and user_ind_columns.table_name = ‘你想要查询的表名字’;

--建立一个唯一索引
ALTER TABLE CMCS3_FARE ADD CONSTRAINT VOUCHERNO_UNIQUE UNIQUE (NAME);
--删除一个唯一索引
ALTER TABLE CMCS3_FARE drop CONSTRAINT VOUCHERNONAME_UNIQUE;

猜你喜欢

转载自2594082lhj.iteye.com/blog/1693801