AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 261945
Accepted
FrenkyB
FrenkyB
Asked: 2020-03-15 00:05:40 +0800 CST2020-03-15 00:05:40 +0800 CST 2020-03-15 00:05:40 +0800 CST

Oracle新创建的数据库充满了数据表

  • 772

我刚刚使用 oracle 数据库配置助手创建了我的第一个数据库。

在此处输入图像描述

基本上没什么特别的,数据库创建成功。我不明白的是为什么数据库中已经有这么多表?oracle如何创建空数据库?

在此处输入图像描述

oracle oracle-19c
  • 2 2 个回答
  • 80 Views

2 个回答

  • Voted
  1. Best Answer
    Bjarte Brandt
    2020-03-15T01:36:09+08:002020-03-15T01:36:09+08:00

    只是给你打个比方。当您安装 Windows 操作系统或 Linux 操作系统时,您会期望文件系统上的文件为零吗?这同样适用于 Oracle 数据库。创建 Oracle 数据库后,将有大量对象(表、函数、过程、索引、包等)构成您的 Oracle 数据库。所有这些对象都归 SYS、SYSTEM、.. 拥有(还有更多)。

    当您使用数据库的不同功能时,这些所有者和对象就会发挥作用。请记住,Oracle 数据库已经开发了 40 多年,并且有大量的特性!

    现在您要创建一个空数据库。让我们再次应用操作系统类比。您将创建一个新用户... /home/myuser。这也正是您在 Oracle 数据库中所做的事情。

    Oracle 数据库可以处理数以千计的用户和模式。(模式 = 对象的所有者,用户 = 操作已创建的对象(DML - 选择、插入、更新、删除))。

    -- *nix (example: export TWO_TASK=localhost:1521/SERVICE_NAME)
    export TWO_TASK=MY_DB_SERVICE
    -- Windows
    set LOCAL=MY_DB_SERVICE
    
    sqlplus system/password
    
    -- this user is the schema. The owner of your objects.
    create user myschema identified by &password
    default tablespace USERS
    temporary tablespace TEMP
    quota unlimited on USERS;     
    
    -- grant privs to the schema
    grant create session, resource to myschema;
    
    -- yes, we need to take security into account.
    create role myschema_ro;
    create role myschema_rw;
    
    -- lets login as myschema
    sqlplus myschema/password
    
    -- your database or schema is empty, now create all objects...
    create table t (x int);
    
    -- grant access to object
    grant select on t to myschema_rw; 
    
    -- we are done with the creation of the schema  
    
    sqlplus system/password
    
    -- no one is going to login as schema owner. 
    -- you only unlock this account when you do schema changes
    alter user myschema account lock;
    
    -- time to create your app-user-account who is going to access 
    -- the database/schema
    create user myapp identified by &password;
    
    -- grant privileges for your app-user
    grant create session, myschema_rw to myapp;
    
    -- login
    sqlplus myapp/password
    
    -- you will see your schema objects are listed
    select object_name from all_objects;
    
    -- now, if you want to avoid schema-prefixing (select * from myschema.t) there are some options
    -- the first thing you do in your app
    alter session set current_schema = MYSCHEMA;
    
    -- now you can do: t is owned by myschema
    select * from t;
    
    -- you can create a trigger (log in as myschema)
    create or replace trigger after_logon_trg
    after logon on myschema.schema
    begin
      execute immediate 'alter session set current_schema = MYSCHEMA';
    end;
    /
    

    您现在已准备好在您的对象受到保护的 Oracle 数据库服务器(实例)上创建一个空数据库(= Oracle 术语中的模式)。

    澄清一下:数据库是磁盘上的一组文件,具有一个或多个模式(除了 sys/system),实例是一个正在运行的系统,由磁盘上的文件和定义工作的内存结构组成一块软件。

    祝你好运!

    • 5
  2. Phill W.
    2020-03-18T04:33:18+08:002020-03-18T04:33:18+08:00

    为什么数据库中已经有这么多表?如何在 Oracle 中创建空数据库?

    那是一个“空”的Oracle数据库!!

    Oracle 数据库是大而复杂的野兽,有很多(和很多)你 [几乎]不必担心的内部工作。作为 DBA,您需要了解它们,但仅此而已。

    您放入此数据库的任何表等都将进入其他表空间中的其他模式,并且您对其授予适当的权限。然后,您创建帐户以使用这些表格,而这些帐户将只能看到这些表格。

    • 1

相关问题

  • Oracle 中的数据库备份 - 导出数据库还是使用其他工具?

  • ORDER BY 使用文本列的自定义优先级

  • 舒服的sqlplus界面?[关闭]

  • 如何在数据库中找到最新的 SQL 语句?

  • 如何使用正则表达式查询名称?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve