Creating Schema in Greenplum database

Schemas are a way to logically organize objects and data in a database. Schemas allow you to have more than one object (such as tables) with the same name in the database without conflict, as long as they are in different schemas.

The Default ‘Public’ Schema

Every newly created database has a default schema named public. If you do not create any schemas of your own, objects will be created in the public schema by default. All database roles (users) have CREATE and USAGE privileges in the public schema by default. Any other schemas you create, you will have to grant the appropriate privileges so that users can access the schema.

Creating a Schema

Use the CREATE SCHEMA command to create a new schema. For example:
=> CREATE SCHEMA myschema;

To create or access objects in a schema, write a qualified name consisting of the schema name and table name separated by a dot. For example:
schema.table

You may want to create a schema owned by someone else (since this is one of the ways to restrict the activities of your users to well-defined namespaces). The syntax for that is:

=> CREATE SCHEMA schemaname AUTHORIZATION username;


Comments