Wednesday, December 2, 2009

Schema

Schema :
  • A PostgreSQL database cluster contains one or more named databases.
  • A database contains one or more named schemas, which in turn contain tables.
  • The same object name can be used in different schemas without conflict;
  • A user can access objects in any of the schemas in the database he is connected to, if he has privileges to do so.
Why Schemas :
  • There are several reasons why one might want to use schemas :
    – To allow many users to use one database without interfering with each other.
    – To organize database objects into logical groups to make them more manageable.
    – Third-party applications can be put into separate schemas so they cannot collide with the names of other objects.
Creating a Schema :
  • To create a schema, use the CREATE SCHEMA command.
  • Give the schema a name preferably same as the user name so that it gets associated
    automatically.
  • For example: CREATE SCHEMA training;
  • Objects in this schema can be referred using schema.table for e.g training.students.

Tuesday, December 1, 2009

Using DDL Statements to Create and Manage Tables

Database Objects :


Naming Rules :

Table names and column names:
– Must begin with a letter
– Must be 1–30 characters long
– Must contain only A–Z, a–z, 0–9, _, and $
– Must not duplicate the name of another object owned by the same user
– Must not be an PostgreSQL server reserved word

Followers