A database contains one or more named schemas, and the schema can contain database objects such as tables. Patterns are a bit like namespaces, and we can use the same names in different namespaces without conflicting. The pattern is not strictly separate, it is just a logical distinction.
Schema creation Syntax format: Create schema schema name;
Schema deletion syntax format: drop schema name [cascade];
When we use cascade when we delete the schema, which is called cascade Delete, it deletes the schema and all its objects.
When we use a database object, we can use its full name to locate, but this is usually very cumbersome, so we can set the value of Search_path, its syntax format is: set Search_path to mode 1, Mode 2 ...;
Of course we can also check the current search path through show Search_path .
By default, users do not see objects in the pattern that are not owned by them, and in order for them to see that the owner of the pattern needs to give the usage permission on the schema.
We can also associate the user name with the schema name so that we associate the pattern to the specified role in the format: CREATE schema name AUTHORIZATION user name;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Sinsing analysis on the mode in PostgreSQL