【发布时间】:2018-05-17 14:58:43
【问题描述】:
我在本地机器上安装了 Oracle 11g 并创建了多个表。现在我想将我的本地数据库副本共享给整个团队,以便他们可以使用相同的表而无需重新创建它们。 (我不希望他们使用我的本地机器作为服务器) 有什么办法可以做到这一点?这样我可以节省几天的时间
【问题讨论】:
我在本地机器上安装了 Oracle 11g 并创建了多个表。现在我想将我的本地数据库副本共享给整个团队,以便他们可以使用相同的表而无需重新创建它们。 (我不希望他们使用我的本地机器作为服务器) 有什么办法可以做到这一点?这样我可以节省几天的时间
【问题讨论】:
在我看来,如果您不希望他们连接到您的计算机(即,它就像数据库服务器一样),每个人都可能不得不在他/她自己的数据库上工作,对吧?这意味着他们所有人都必须将数据库安装到他们的计算机上。此外,这意味着您将来将无法共享代码或数据。您(或其他任何人)所做的更改不会对您团队的其他成员可见。
您的任务可以通过两种方式完成。第一个是提供 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:\>
如你所见,两个简单的命令就可以解决你所有的问题:)
【讨论】: