postgreSQL: Multiple schemas in one database

How to query a table from other schema than "pulic" schema?

If a database contains more than one named schemas, you can query use schema_name.table_name to query the content of the table.

select * from myschema.mytable;

create table myschema.mytable(

......

);

You alswaysa can simplify this by changing the search path.

SHOW search_path;

will show the current search path. The follwoing command will add the schema myachema into the search_path. so next time you do not need to use myschema.mytable to query data.

SET search_path TO myschema,public;

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...