Oracle创建用户并指定表空间&导入导出dmp

Oracle创建用户并指定表空间&导入导出dmp

  • 创建表空间
  • 创建用户并指定表空间
  • 给用户赋权
  • 导出数据库前的空表少表处理方法
  • 导出某个用户数据库dmp文件
  • 导入数据库
  • 查询oracle数据库表中字段的信息

创建表空间

create tablesapce tbspace
logging
datafile ‘…\ordata\tbspace.dbf’
size 32M
autoextend on
next 32M maxsize unlimited
extent management local;

创建用户并指定表空间

create user username identified by password default tablespace tbspace;

给用户赋权

grant dba,resource,connect to username;

导出数据库前的空表少表处理方法

执行查询出的脚本
select ‘alter table ‘|| table_name ||’ allocate extent ;’ from user_tables where num_rows=0;

导出某个用户数据库dmp文件

exp username/[email protected]:1521/orcl file=C:data.dmp owner=username

导入数据库

imp username/[email protected]:1521/orcl file=C:data.dmp fromuser=fromuser touser=touser

查询oracle数据库表中字段的信息

--字段名,数据类型,长度,是否为空,’’,’’,’’,’’,字段注释
select utcs.COLUMN_NAME,
utcs.DATA_TYPE,
utcs.DATA_LENGTH,
utcs.NULLABLE,
‘’,
‘’,
‘’,
‘’,
uuc.comments
from user_tab_cols utcs
left join user_col_comments uuc
on uuc.column_name = utcs.COLUMN_NAME
and uuc.table_name = utcs.TABLE_NAME
where utcs.TABLE_NAME = ‘tablename’;

你可能感兴趣的:(常用语句整理)