如何在 SQL*Plus 中组织表?

发布于 2024-09-14 15:29:06 字数 193 浏览 13 评论 0原文

我正在练习SQL,突然我有这么多表。 组织它们的好方法是什么?有没有办法将它们放入不同的目录?

或者是创建表空间的唯一选择如此处所述

I am practicing SQL, and suddenly I have so many tables. What is a good way to organize them? Is there a way to put them into different directories?

Or is the only option to create a tablespace as explained here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人生百味 2024-09-21 15:29:06

这取决于您所说的组织的含义 - 表空间实际上专注于组织存储。

对于组织表,将它们分组到不同的 SCHEMAS 中可能更有用。
这更像是“命名空间”的概念 - 即 schema1.people 与 schema2.people 不同。

将操作数据和配置数据分离到不同的模式中通常是有好处的。

如果您正在谈论在模式中组织表 - 并且在现实世界的应用程序中,一个模式中拥有数百个表并不是未知的 - 那么您真正能做的就是想出良好的命名约定。

有些地方将表分组,并在表名的开头添加前缀。就我个人而言,我认为这会导致重复 - EMP_ADDRESSES 和 CUST_ADDRESSES 而不是正确链接的地址。

It depends what you mean by organise - tablespaces are really focused on organising storage.

For organising tables, grouping them into different SCHEMAS may be more useful.
This is more like the concept of a 'namespace' - i.e. schema1.people is not the same as schema2.people.

It often pays off to separate Operational and Configuration data into different schemas.

If you are talking about organising tables within a schema - and in a real world application, having hundreds of tables in one schema is not unknown - then all you can really do is come up with good naming conventions.

Some places group tables with prefixes at the start of the table name. Personally, I think this leads to duplication - EMP_ADDRESSES and CUST_ADDRESSES rather than a properly linked Addresses.

山田美奈子 2024-09-21 15:29:06

这取决于您为什么要组织它们以及为什么(以及何时)创建它们。如果当您查看 user_tables 时,这个数字非常大,那么拆分表空间不会有太大帮助,因为您需要指定每次要查询哪个表空间。并没有真正的“目录”等价物。

如果您创建练习表只是为了试验小型项目,那么一种选择可能是为每个项目创建一个新的 Oracle 用户,并在该用户模式下创建所有相关表。然后,您只有在以该用户身份登录并处理该项目时才会看到相关表。这样做的优点是允许您重用表名,这可以简化您在做许多类似项目时的事情。

当你确定你已经完成了一些实验时,你可能还应该考虑稍微整理一下,扔掉桌子。

It depends why you want to organise them and why (and when) you're creating them. If the number is just overwhelming when you look in, say, user_tables, then splitting into tablespaces wont help much as you'd need to specify which one you wanted to query each time. And there isn't really a 'directory' equivalent.

If you're creating practice tables just to experiment with mini projects, then one option might be to create a new Oracle user for each project and create all the related tables under that user schema. Then you'd only see relevant tables when logged in as that user, while working on that project. This has the advantage of allowing you to reuse table names, which can simplify things a bit of you're doing lots of similar projects.

You should also probably be thinking about tidying up a bit, dropping tables when you're sure you've finished that bit of experimentation.

思念满溢 2024-09-21 15:29:06

它们已经组织好了,因为它们位于数据库中,并且您有一个存储库。

They are allready organised because they are in a database and you have a repository.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文