5.12. PostgreSQL mode (SCHEMA)

发布时间 :2025-10-25 12:30:47 UTC      

The PostgreSQL schema (SCHEMA) can look like a collection of tables.

A schema can contain views, indexes, data types, functions, operators, and so on.

The same object name can be used in different schemas without conflicts; for example, both schema1 and myschema can contain a table named mytable.

Advantages of using patterns:

  • Allow multiple users to use a database without interfering with each other.

  • Organize database objects into logical groups for easier management.

  • Objects applied by third parties can be placed in separate schemas so that they do not conflict with the names of other objects.

Patterns are similar to directories at the operating system layer, but patterns cannot be nested.

5.12.1. Grammar

We can use it. CREATE SCHEMA Statement to create a pattern, the syntax format is as follows:

CREATE SCHEMA myschema.mytable (
...
);

5.12.2. Example

Next we connect to runoobdb to create the schema myschema:

runoobdb=# create schema myschema;
CREATE SCHEMA

The output “CREATE SCHEMA” indicates that the schema was created successfully.

Next let’s create another table:

runoobdb=# create table myschema.company(
   ID   INT              NOT NULL,
   NAME VARCHAR (20)     NOT NULL,
   AGE  INT              NOT NULL,
   ADDRESS  CHAR (25),
   SALARY   DECIMAL (18, 2),
   PRIMARY KEY (ID)
);

The above command creates an empty table, and we use the following SQL to see if the table is created:

runoobdb=# select * from myschema.company;
 id | name | age | address | salary
----+------+-----+---------+--------
(0 rows)

5.12.3. Delete Mod

Delete an empty schema (where all objects have been deleted):

DROP SCHEMA myschema;

Delete a schema and all objects contained in it:

DROP SCHEMA myschema CASCADE;
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.