문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top