最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。
In PostgreSQL ALTER TABLE The command is used to add, modify, and delete a column that already exists in a table.
Besides, you can also use it. ALTER TABLE Command to add and remove constraints. Use On an existing table To modify a column in a table Add to a column in the table Give a column in a table Give to the table Give the watch If it’s MYSQL, the code looks like this: If it’s MYSQL, the code looks like this: Create the COMPANY table ( 下载 COMPANY SQL 文件 ), the data are as follows: The following example adds a new column to this table: Now the watch looks like this: Delete the following example The results are as follows: 5.35.1. Grammar ¶
ALTER TABLE The syntax to add a column to an existing table is as follows:ALTER TABLE table_name ADD column_name datatype;
DROP COLUMN (delete column), the syntax is as follows:ALTER TABLE table_name DROP COLUMN column_name;
DATA TYPE (data type), the syntax is as follows:ALTER TABLE table_name ALTER COLUMN column_name TYPE datatype;
NOT NULL Constraints, the syntax is as follows:ALTER TABLE table_name ALTER column_name datatype NOT NULL;
ADD UNIQUE CONSTRAINT (add UNIQUE constraint), the syntax is as follows:ALTER TABLE table_name ADD CONSTRAINT MyUniqueConstraint UNIQUE(column1, column2...);
ADD CHECK CONSTRAINT (add CHECK constraint), the syntax is as follows:ALTER TABLE table_name ADD CONSTRAINT MyUniqueConstraint CHECK (CONDITION);
ADD PRIMARY KEY (add primary key), the syntax is as follows:ALTER TABLE table_name ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...);
DROP CONSTRAINT (delete constraint), the syntax is as follows:ALTER TABLE table_name DROP CONSTRAINT MyUniqueConstraint;
ALTER TABLE table_name DROP INDEX MyUniqueConstraint;
DROP PRIMARY KEY (delete the primary key), the syntax is as follows:ALTER TABLE table_name DROP CONSTRAINT MyPrimaryKey;
ALTER TABLE table_name DROP PRIMARY KEY;
5.35.2. Example ¶
runoobdb# select * from COMPANY; id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000 (7 rows)
runoobdb=# ALTER TABLE COMPANY ADD GENDER char(1);
id | name | age | address | salary | gender ----+-------+-----+-------------+--------+-------- 1 | Paul | 32 | California | 20000 | 2 | Allen | 25 | Texas | 15000 | 3 | Teddy | 23 | Norway | 20000 | 4 | Mark | 25 | Rich-Mond | 65000 | 5 | David | 27 | Texas | 85000 | 6 | Kim | 22 | South-Hall | 45000 | 7 | James | 24 | Houston | 10000 | (7 rows)
GENDER Column:runoobdb=# ALTER TABLE COMPANY DROP GENDER;
id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000