【问题标题】:How to share local Oracle 11g DSN to others?如何将本地 Oracle 11g DSN 共享给他人?
【发布时间】:2018-05-17 14:58:43
【问题描述】:

我在本地机器上安装了 Oracle 11g 并创建了多个表。现在我想将我的本地数据库副本共享给整个团队,以便他们可以使用相同的表而无需重新创建它们。 (我不希望他们使用我的本地机器作为服务器) 有什么办法可以做到这一点?这样我可以节省几天的时间

【问题讨论】:

    标签: database oracle oracle11g


    【解决方案1】:

    在我看来,如果您不希望他们连接到您的计算机(即,它就像数据库服务器一样),每个人都可能不得不在他/她自己的数据库上工作,对吧?这意味着他们所有人都必须将数据库安装到他们的计算机上。此外,这意味着您将来将无法共享代码或数据。您(或其他任何人)所做的更改不会对您团队的其他成员可见。

    您的任务可以通过两种方式完成。第一个是提供 CREATE TABLE 脚本,可能是 INSERT INTO 示例数据,以及 CREATE PROCEDURE / FUNCTION / PACKAGE / 其他。所有这些都可以放入他们将在数据库中运行的 .SQL 文件中。

    另一个 - 并且可能是更好的选择 - 是导出您的架构。在这种情况下,我建议您使用 original EXP(导出)实用程序。结果是一个 DMP(二进制)文件。一旦他们得到它,他们将使用IMP 实用程序(导入)并将所有内容导入他们的数据库。

    这是一个例子。

    你应该运行这个:

    M:\>exp scott/tiger@orcl file=test.dmp
    
    Export: Release 11.2.0.2.0 - Production on ╚et Svi 17 08:53:02 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Tes
    Export done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user SCOTT
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user SCOTT
    About to export SCOTT's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export SCOTT's tables via Conventional Path ...
    . . exporting table                          BONUS          0 rows exported
    . . exporting table                           DEPT          4 rows exported
    . . exporting table                          DUMMY          1 rows exported
    . . exporting table                            EMP         14 rows exported
    . . exporting table                       SALGRADE          5 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
    
    M:\>
    

    他们应该运行这个:

    M:\>imp mike/lion@orcl file=test.dmp full=y
    
    Import: Release 11.2.0.2.0 - Production on ╚et Svi 17 08:57:19 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Tes
    
    Export file created by EXPORT:V11.02.00 via conventional path
    
    Warning: the objects were exported by SCOTT, not by you
    
    import done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    . importing SCOTT's objects into MIKE
    . . importing table                        "BONUS"          0 rows imported
    . . importing table                         "DEPT"          4 rows imported
    . . importing table                        "DUMMY"          1 rows imported
    . . importing table                          "EMP"         14 rows imported
    . . importing table                     "SALGRADE"          5 rows imported
    Import terminated successfully without warnings.
    
    M:\>
    

    如你所见,两个简单的命令就可以解决你所有的问题:)

    【讨论】:

    • 我建议不要使用旧的 exp/imp 命令。它们的继任者 expdp 和 impdp 从版本 10 开始可用,并且在较新的数据库版本中有许多 exp 和 imp 不能正确处理的特性(空表:serverfault.com/q/143794/461144、XMLType 列、sys_context,...)跨度>
    • 是的,@Frank,我同意。然而,不同意。我说,在这种情况下我会使用原来的 EXP 和 IMP。关于 OP 想要做什么,需要创建目录并授予所需权限的 Data Pump 可能是矫枉过正。我认为(真的,我可能错了)那些男人和女孩不会在乎你提到的东西,而不是在他们项目的当前阶段(也许是家庭作业?)。但是,我没有异议——如果他们想使用 Data Pump,那就去吧。对他们来说,事情不会那么简单。
    • 很公平。你是对的 - 设置数据泵比使用 exp/imp 更复杂。
    • 谢谢@FrankSchmitt。在哪里可以找到导出的 test.dmp 文件?我应该将这个 .dmp 文件粘贴到我要导入的第二个系统的哪里?
    • 我相信我在发布如何使用 EXP 和 IMP 的示例时没有使用隐形墨水。两者都在操作系统命令提示符下执行。 DMP 在当前目录中创建。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    • 1970-01-01
    • 1970-01-01
    • 2015-11-18
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多