加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle、postgres、mysql数据库的建库、创建用户、导人导出备份

发布时间:2020-12-12 13:25:09 所属栏目:百科 来源:网络整理
导读:? 本文包含的内容:使用命令操作oracle、postgres、mysql的导入导出,包括登录到数据 注:我在公司使用的是Center OS操作系统,所以oracle和postgres均是在Linux使用,在其他工具中未测试;mysql是在自己的笔记本电脑上使用的,均在Linux和Dos命令下使用过。

?

本文包含的内容:使用命令操作oracle、postgres、mysql的导入导出,包括登录到数据

注:我在公司使用的是Center OS操作系统,所以oracle和postgres均是在Linux使用,在其他工具中未测试;mysql是在自己的笔记本电脑上使用的,均在Linux和Dos命令下使用过。

1.oracle

  • 切换到oracle用户: su - oracle
  • 登陆数据库:sqlplus 用户名/密码@172.10.103.78:1521/orcl as sysdba;(用户名可使用系统的: sys)
  • 创建表空间:create tablespace 表空间名 datafile ‘/xx/xxx/xx.dbf‘ size 1000M autoextend on next 100M;
  • 创建用户:create user 用户名 identified by 密码 default tablespace 表空间;
  • 授权:grant connect,resource,dba to 用户名; (自己视情况而定)

  

  注:导出表之前可能需要进行空表的处理:

    select count(1) from user_tables where num_rows = 0;  --查询有多少个空表

    select ‘alter table? ‘ || table_name || ‘ allocate extent ; ‘ from user_tables where num_rows? = 0;

  • ?导出:exp 用户名/密码@ip:sid/orcl? file=/xxx/xxx/xx.dmp   如:exp platform/[email?protected]:1521/orcl file=/data/oracle/platform_20180824.dmp;
  • ?导入:imp 用户名/密码@ip:sid/orcl file=/xxx/xxx/xxx.dmp ignore=y full=y ;? ? ?如:imp platform/[email?protected]:1521/orcl file=/data/oracle/platform_20180824.dmp ignore=y full=y;

  

  其他操作

  •   查用户:select * from dba_users;
  • ? ? ? ?查询使用表空间:select tablespace_name from user_tables group by tablespace_name;
  • ? ? ? ?查询当前用户默认表空间:select default_tablespace from dba_users where username=‘用户名‘;
  • ? ? ? ?查看表空间名,路径:select? t1.name,t2.name from v$tablespace t1,v$datafile t2 where t1.ts #=t2.tx#;

?2.postgres

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读