Académique Documents
Professionnel Documents
Culture Documents
html
why schema?
if you want to create schema owned by another user other than you.
Public schema is default place where tables are created if we didnt specify schema.
...
);
Search Paths
The system determines which table is meant by following a search path, which is a list of schemas to
look in,if the schema.mytable is referred as mytable.
The first schema named in the search path is called the current schema.
Aside from being the first schema searched, it is also the schema in which new tables will be created if
the CREATE TABLE command does not specify a schema name.
SHOW search_path;
o/p
search_path
--------------
"$user",public
The first element specifies that a schema with the same name as the current user is to be searched.
If no such schema exists, the entry is ignored. The second element refers to the public schema that we
have seen already.
----------------
N users can share a schema. But need permission to access the schema.
To allow that, the owner of the schema must grant the USAGE privilege on the schema.
To actually access the table ( any other db objects ) he needs certain specific grants.
NOTE: that by default, everyone has CREATE and USAGE privileges on the schema public.
which contains the system tables and all the built-in data types, functions, and operators. pg_catalog is
always effectively part of the search path.
DB and DB objects
-----------------
Generally, every database object (tables, functions, etc.) belongs to one and only one database.
(However there are a few system catalogs, for example pg_database, that belong to a whole cluster and
are accessible from each database within the cluster.)
Tablespaces
-----------
This can be a list of tablespace names, rather than only one, so that the load associated with temporary
objects can be spread over multiple tablespaces.
A random member of the list is picked each time a temporary object is to be created.
Two tablespaces are automatically created when the database cluster is initialized.
The pg_default tablespace is the default tablespace of the template1 and template0 databases
Once created, a tablespace can be used from any database, provided the requesting user has sufficient
privilege.
This means that a tablespace cannot be dropped until all objects in all databases using the tablespace
have been removed.
BKP
===
1) bkp ( Live: pg_dump dbname > outfile and psql dbname < infile , offline: )
2) statistics (vaccuming)
3) log maintenance (here is a built-in log rotation facility, which you can use by setting the configuration
parameter logging_collector to true in postgresql.conf)
4) reindex