本文介绍AnalyticDB PostgreSQL版支持的SQL命令及语法参考。

说明

AnalyticDB PostgreSQL版Serverless模式暂不支持部分语法,具体限制,请参见Serverless模式

ABORT

终止当前事务。

ABORT [WORK | TRANSACTION]

更多信息,请参见ABORT

ALTER AGGREGATE

改变聚集函数的定义。

ALTER AGGREGATE name ( type [ , ... ] ) RENAME TO new_name
ALTER AGGREGATE name ( type [ , ... ] ) OWNER TO new_owner
ALTER AGGREGATE name ( type [ , ... ] ) SET SCHEMA new_schema

更多信息,请参见ALTER AGGREGATE

ALTER CONVERSION

修改转换的定义。

ALTER CONVERSION name RENAME TO newname
ALTER CONVERSION name OWNER TO newowner

更多信息,请参见ALTER CONVERSION

ALTER DATABASE

修改数据库属性。

ALTER DATABASE name [ WITH CONNECTION LIMIT connlimit ]
ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT }
ALTER DATABASE name RESET parameter
ALTER DATABASE name RENAME TO newname
ALTER DATABASE name OWNER TO new_owner

更多信息,请参见ALTER DATABASE

ALTER DOMAIN

改变域的定义。

ALTER DOMAIN name { SET DEFAULT expression | DROP DEFAULT }
ALTER DOMAIN name { SET | DROP } NOT NULL
ALTER DOMAIN name ADD domain_constraint
ALTER DOMAIN name DROP CONSTRAINT constraint_name [RESTRICT | CASCADE]
ALTER DOMAIN name OWNER TO new_owner
ALTER DOMAIN name SET SCHEMA new_schema

更多信息,请参见ALTER DOMAIN

ALTER EXTERNAL TABLE

改变外部表的定义。

ALTER EXTERNAL TABLE name RENAME [COLUMN] column TO new_column
ALTER EXTERNAL TABLE name RENAME TO new_name
ALTER EXTERNAL TABLE name SET SCHEMA new_schema
ALTER EXTERNAL TABLE name action [, ... ]

更多信息,请参见ALTER EXTERNAL TABLE

ALTER FUNCTION

改变函数的定义。

ALTER FUNCTION name ( [ [argmode] [argname] argtype [, ...] ] ) 
   action [, ... ] [RESTRICT]
ALTER FUNCTION name ( [ [argmode] [argname] argtype [, ...] ] )
   RENAME TO new_name
ALTER FUNCTION name ( [ [argmode] [argname] argtype [, ...] ] ) 
   OWNER TO new_owner
ALTER FUNCTION name ( [ [argmode] [argname] argtype [, ...] ] ) 
   SET SCHEMA new_schema

更多信息,请参见ALTER FUNCTION

ALTER GROUP

改变角色名字或者成员信息。

ALTER GROUP groupname ADD USER username [, ... ]
ALTER GROUP groupname DROP USER username [, ... ]
ALTER GROUP groupname RENAME TO newname

更多信息,请参见ALTER GROUP

ALTER INDEX

改变索引的定义。

ALTER INDEX name RENAME TO new_name
ALTER INDEX name SET TABLESPACE tablespace_name
ALTER INDEX name SET ( FILLFACTOR = value )
ALTER INDEX name RESET ( FILLFACTOR )

更多信息,请参见ALTER INDEX

ALTER OPERATOR

改变操作符的定义。

ALTER OPERATOR name ( {lefttype | NONE} , {righttype | NONE} ) 
   OWNER TO newowner

更多信息,请参见ALTER OPERATOR

ALTER RESOURCE QUEUE

修改资源队列的限制。

ALTER RESOURCE QUEUE name WITH ( queue_attribute=value [, ... ] )

更多信息,请参见ALTER RESOURCE QUEUE

ALTER ROLE

修改一个数据库角色(用户或组)。

ALTER ROLE name [ [ WITH ] option [ ... ] ]

WHERE option can be:
 SUPERUSER | NOSUPERUSER
 | CREATEDB | NOCREATEDB
 | CREATEROLE | NOCREATEROLE
 | CREATEEXTTABLE | NOCREATEEXTTABLE [ ( attribute='value' [, ...] )
 WHERE attributes and values are:
 type='readable'|'writable'
 protocol='gpfdist'|'http'
 | INHERIT | NOINHERIT
 | LOGIN | NOLOGIN
 | REPLICATION | NOREPLICATION
 | CONNECTION LIMIT connlimit
 | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
 | VALID UNTIL 'timestamp'
ALTER ROLE name RENAME TO new_name
ALTER ROLE { name | ALL } [ IN DATABASE database_name ]
 SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER ROLE { name | ALL } [ IN DATABASE database_name ]
 SET configuration_parameter FROM CURRENT
ALTER ROLE { name | ALL } [ IN DATABASE database_name ]
 RESET configuration_parameter
ALTER ROLE { name | ALL } [ IN DATABASE database_name ] RESET ALL
ALTER ROLE name RESOURCE QUEUE {queue_name | NONE}
ALTER ROLE name RESOURCE GROUP {group_name | NONE}

更多信息,请参见ALTER ROLE

ALTER SCHEMA

改变模式的定义。

ALTER SCHEMA name RENAME TO newname

ALTER SCHEMA name OWNER TO newowner

更多信息,请参见ALTER SCHEMA

ALTER SEQUENCE

改变序列生成器的定义。

ALTER SEQUENCE name [INCREMENT [ BY ] increment] 
     [MINVALUE minvalue | NO MINVALUE] 
     [MAXVALUE maxvalue | NO MAXVALUE] 
     [RESTART [ WITH ] start] 
     [CACHE cache] [[ NO ] CYCLE] 
     [OWNED BY {table.column | NONE}]
ALTER SEQUENCE name SET SCHEMA new_schema

更多信息,请参见ALTER SEQUENCE

ALTER TABLE

改变表的定义。

ALTER TABLE [ONLY] name RENAME [COLUMN] column TO new_column

ALTER TABLE name RENAME TO new_name

ALTER TABLE name SET SCHEMA new_schema

ALTER TABLE [ONLY] name SET 
     DISTRIBUTED BY (column, [ ... ] ) 
   | DISTRIBUTED RANDOMLY 
   | WITH (REORGANIZE=true|false)

ALTER TABLE [ONLY] name action [, ... ]

ALTER TABLE name
   [ ALTER PARTITION { partition_name | FOR (RANK(number)) 
   | FOR (value) } partition_action [...] ] 
   partition_action

更多信息,请参见ALTER TABLE

ALTER TYPE

改变数据类型的定义。

ALTER TYPE name
   OWNER TO new_owner | SET SCHEMA new_schema

更多信息,请参见ALTER TYPE

ALTER USER

修改数据库角色(用户)的定义。

ALTER USER name RENAME TO newname

ALTER USER name SET config_parameter {TO | =} {value | DEFAULT}

ALTER USER name RESET config_parameter

ALTER USER name [ [WITH] option [ ... ] ]

更多信息,请参见ALTER USER

ANALYZE

收集关于数据库的数据。

ANALYZE [VERBOSE] [ROOTPARTITION [ALL] ] 
   [table [ (column [, ...] ) ]]

更多信息,请参见ANALYZE

BEGIN

启动事务块。

BEGIN [WORK | TRANSACTION] [transaction_mode]
      [READ ONLY | READ WRITE]

更多信息,请参见BEGIN

CHECKPOINT

强制事务记录检查点。

CHECKPOINT

更多信息,请参见CHECKPOINT

CLOSE

关闭游标。

CLOSE cursor_name

更多信息,请参见CLOSE

CLUSTER

根据索引对磁盘上的堆存储表进行物理重新排序。不推荐使用该操作。

CLUSTER indexname ON tablename

CLUSTER tablename

CLUSTER

更多信息,请参见CLUSTER

COMMENT

定义或者修改对一个对象的注释。

COMMENT ON
{ TABLE object_name |
  COLUMN table_name.column_name |
  AGGREGATE agg_name (agg_type [, ...]) |
  CAST (sourcetype AS targettype) |
  CONSTRAINT constraint_name ON table_name |
  CONVERSION object_name |
  DATABASE object_name |
  DOMAIN object_name |
  FILESPACE object_name |
  FUNCTION func_name ([[argmode] [argname] argtype [, ...]]) |
  INDEX object_name |
  LARGE OBJECT large_object_oid |
  OPERATOR op (leftoperand_type, rightoperand_type) |
  OPERATOR CLASS object_name USING index_method |
  [PROCEDURAL] LANGUAGE object_name |
  RESOURCE QUEUE object_name |
  ROLE object_name |
  RULE rule_name ON table_name |
  SCHEMA object_name |
  SEQUENCE object_name |
  TABLESPACE object_name |
  TRIGGER trigger_name ON table_name |
  TYPE object_name |
  VIEW object_name } 
IS 'text'

更多信息,请参见COMMENT

COMMIT

提交当前事务。

COMMIT [WORK | TRANSACTION]

更多信息,请参见COMMIT

COPY

在文件和表之间拷贝数据。

COPY table [(column [, ...])] FROM {'file' | STDIN}
     [ [WITH] 
       [BINARY]
       [OIDS]
       [HEADER]
       [DELIMITER [ AS ] 'delimiter']
       [NULL [ AS ] 'null string']
       [ESCAPE [ AS ] 'escape' | 'OFF']
       [NEWLINE [ AS ] 'LF' | 'CR' | 'CRLF']
       [CSV [QUOTE [ AS ] 'quote'] 
            [FORCE NOT NULL column [, ...]]
       [FILL MISSING FIELDS]
       [[LOG ERRORS]  
       SEGMENT REJECT LIMIT count [ROWS | PERCENT] ]

COPY {table [(column [, ...])] | (query)} TO {'file' | STDOUT}
      [ [WITH] 
        [ON SEGMENT]
        [BINARY]
        [OIDS]
        [HEADER]
        [DELIMITER [ AS ] 'delimiter']
        [NULL [ AS ] 'null string']
        [ESCAPE [ AS ] 'escape' | 'OFF']
        [CSV [QUOTE [ AS ] 'quote'] 
             [FORCE QUOTE column [, ...]] ]
      [IGNORE EXTERNAL PARTITIONS ]

更多信息,请参见COPY

CREATE AGGREGATE

定义一个新的聚集函数。

CREATE [ORDERED] AGGREGATE name (input_data_type [ , ... ]) 
      ( SFUNC = sfunc,
        STYPE = state_data_type
        [, PREFUNC = prefunc]
        [, FINALFUNC = ffunc]
        [, INITCOND = initial_condition]
        [, SORTOP = sort_operator] )

更多信息,请参见CREATE AGGREGATE

CREATE CAST

定义一个新的CAST。

CREATE CAST (sourcetype AS targettype) 
       WITH FUNCTION funcname (argtypes) 
       [AS ASSIGNMENT | AS IMPLICIT]

CREATE CAST (sourcetype AS targettype) WITHOUT FUNCTION 
       [AS ASSIGNMENT | AS IMPLICIT]

更多信息,请参见CREATE CAST

CREATE CONVERSION

定义一个新的编码转换。

CREATE [DEFAULT] CONVERSION name FOR source_encoding TO 
     dest_encoding FROM funcname

更多信息,请参见CREATE CONVERSION

CREATE DATABASE

创建一个新的数据库。

CREATE DATABASE name [ [WITH] [OWNER [=] dbowner]
                     [TEMPLATE [=] template]
                     [ENCODING [=] encoding]
                     [CONNECTION LIMIT [=] connlimit ] ]

更多信息,请参见CREATE DATABASE

CREATE DOMAIN

定义一个新的域。

CREATE DOMAIN name [AS] data_type [DEFAULT expression] 
       [CONSTRAINT constraint_name
       | NOT NULL | NULL 
       | CHECK (expression) [...]]

更多信息,请参见CREATE DOMAIN

CREATE EXTENSION

在数据库中注册一个EXTENSION。

CREATE EXTENSION [ IF NOT EXISTS ] extension_name
  [ WITH ] [ SCHEMA schema_name ]
           [ VERSION version ]
           [ FROM old_version ]
           [ CASCADE ]

更多信息,请参见CREATE EXTENSION

CREATE EXTERNAL TABLE

定义一张外部表。

CREATE [READABLE] EXTERNAL TABLE tablename
( columnname datatype [, ...] | LIKE othertable )
LOCATION ('ossprotocol')
FORMAT 'TEXT'
            [( [HEADER]
               [DELIMITER [AS] 'delimiter' | 'OFF']
               [NULL [AS] 'null string']
               [ESCAPE [AS] 'escape' | 'OFF']
               [NEWLINE [ AS ] 'LF' | 'CR' | 'CRLF']
               [FILL MISSING FIELDS] )]
           | 'CSV'
            [( [HEADER]
               [QUOTE [AS] 'quote']
               [DELIMITER [AS] 'delimiter']
               [NULL [AS] 'null string']
               [FORCE NOT NULL column [, ...]]
               [ESCAPE [AS] 'escape']
               [NEWLINE [ AS ] 'LF' | 'CR' | 'CRLF']
               [FILL MISSING FIELDS] )]
[ ENCODING 'encoding' ]
[ [LOG ERRORS [INTO error_table]] SEGMENT REJECT LIMIT count
       [ROWS | PERCENT] ]
CREATE WRITABLE EXTERNAL TABLE table_name
( column_name data_type [, ...] | LIKE other_table )
LOCATION ('ossprotocol')
FORMAT 'TEXT'
               [( [DELIMITER [AS] 'delimiter']
               [NULL [AS] 'null string']
               [ESCAPE [AS] 'escape' | 'OFF'] )]
          | 'CSV'
               [([QUOTE [AS] 'quote']
               [DELIMITER [AS] 'delimiter']
               [NULL [AS] 'null string']
               [FORCE QUOTE column [, ...]] ]
               [ESCAPE [AS] 'escape'] )]
[ ENCODING 'encoding' ]
[ DISTRIBUTED BY (column, [ ... ] ) | DISTRIBUTED RANDOMLY ]
ossprotocol:
   oss://oss_endpoint prefix=prefix_name
    id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]
ossprotocol:
   oss://oss_endpoint dir=[folder/[folder/]...]/file_name
    id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]
ossprotocol:
   oss://oss_endpoint filepath=[folder/[folder/]...]/file_name
id=userossid key=userosskey bucket=ossbucket compressiontype=[none|gzip] async=[true|false]

更多信息,请参见CREATE EXTERNAL TABLE

CREATE FUNCTION

定义一个新的函数。

CREATE [OR REPLACE] FUNCTION name    
    ( [ [argmode] [argname] argtype [ { DEFAULT | = } defexpr ] [, ...] ] )
      [ RETURNS { [ SETOF ] rettype 
        | TABLE ([{ argname argtype | LIKE other table }
          [, ...]])
        } ]
    { LANGUAGE langname
    | IMMUTABLE | STABLE | VOLATILE
    | CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
    | [EXTERNAL] SECURITY INVOKER | [EXTERNAL] SECURITY DEFINE
    | COST execution_cost
    | SET configuration_parameter { TO value | = value | FROM CURRENT }
    | AS 'definition'
    | AS 'obj_file', 'link_symbol' } ...
    [ WITH ({ DESCRIBE = describe_function
           } [, ...] ) ]

更多信息,请参见CREATE FUNCTION

CREATE GROUP

定义一个新的数据库角色。

CREATE GROUP name [ [WITH] option [ ... ] ]

更多信息,请参见CREATE GROUP

CREATE INDEX

定义一个新的索引。

CREATE [UNIQUE] INDEX name ON table
       [USING btree|bitmap|gist]
       ( {column | (expression)} [opclass] [, ...] )
       [ WITH ( FILLFACTOR = value ) ]
       [TABLESPACE tablespace]
       [WHERE predicate]
说明

AnalyticDB PostgreSQL版Serverless实例仅支持创建B-Tree类型索引。

更多信息,请参见CREATE INDEX

CREATE LIBRARY

定义一个用户自定义软件表。

CREATE LIBRARY library_name LANGUAGE [JAVA] FROM oss_location OWNER ownername
CREATE LIBRARY library_name LANGUAGE [JAVA] VALUES file_content_hex OWNER ownername

更多信息,请参见CREATE LIBRARY

CREATE OPERATOR

定义一个新的操作符。

CREATE OPERATOR name ( 
       PROCEDURE = funcname
       [, LEFTARG = lefttype] [, RIGHTARG = righttype]
       [, COMMUTATOR = com_op] [, NEGATOR = neg_op]
       [, RESTRICT = res_proc] [, JOIN = join_proc]
       [, HASHES] [, MERGES]
       [, SORT1 = left_sort_op] [, SORT2 = right_sort_op]
       [, LTCMP = less_than_op] [, GTCMP = greater_than_op] )

更多信息,请参见CREATE OPERATOR

CREATE RESOURCE QUEUE

定义一个新的资源队列。

CREATE RESOURCE QUEUE name WITH (queue_attribute=value [, ... ])

更多信息,请参见CREATE RESOURCE QUEUE

CREATE ROLE

定义一个新的数据库角色(用户或组)。

CREATE ROLE name [[WITH] option [ ... ]]

WHERE option can be:
SUPERUSER | NOSUPERUSER
 | CREATEDB | NOCREATEDB
 | CREATEROLE | NOCREATEROLE
 | CREATEUSER | NOCREATEUSER
 | CREATEEXTTABLE | NOCREATEEXTTABLE
 [ ( attribute='value'[, ...] ) ]
 WHERE attributes and value are:
 type='readable'|'writable'
 protocol='gpfdist'|'http'
 | INHERIT | NOINHERIT
 | LOGIN | NOLOGIN
 | REPLICATION | NOREPLICATION
 | CONNECTION LIMIT connlimit
 | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
 | VALID UNTIL 'timestamp'
 | IN ROLE rolename [, ...]
 | ROLE rolename [, ...]
 | ADMIN rolename [, ...]
 | USER rolename [, ...]
 | SYSID uid [, ...]
 | RESOURCE QUEUE queue_name
 | RESOURCE GROUP group_name
 | [ DENY deny_point ]
 | [ DENY BETWEEN deny_point AND deny_point]

下表列出了数据库角色可使用的属性。

用户属性

描述

CREATEDB | NOCREATEDB

该用户是否允许创建DB,默认为NOCREATEDB。

CREATEROLE | NOCREATEROLE

该用户是否允许创建用户,默认为NOCREATEROLE。

INHERIT | NOINHERIT

该用户是否继承所在组的权限,默认为INHERIT。

LOGIN | NOLOGIN

该用户是否有登录权限。有登录权限的ROLE概念上为USER,没有的相当于为GROUP,用于权限继承。默认为NOLOGIN。

CONNECTION LIMIT connlimit

该用户允许的连接数,默认为-1(无限制)。

CREATEEXTTABLE | NOCREATEEXTTABLE

该用户是否允许创建External Table。默认为NOCREATEEXTTABLE。

PASSWORD 'password'

设置用户登录密码。

ENCRYPTED | UNENCRYPTED

登录密码是否加密。

VALID UNTIL 'timestamp'

登录密码过期时间。

RESOURCE QUEUE queue_name

指定该用户所属资源队列名称。

DENY {deny_interval | deny_point}

在指定时间禁止该用户登录。

更多信息,请参见CREATE ROLE

CREATE RULE

定义一个新的重写规则。

CREATE [OR REPLACE] RULE name AS ON event
  TO table [WHERE condition] 
  DO [ALSO | INSTEAD] { NOTHING | command | (command; command 
  ...) }

更多信息,请参见CREATE RULE

CREATE SCHEMA

定义一个新的SCHEMA。

CREATE SCHEMA schema_name [AUTHORIZATION username] 
   [schema_element [ ... ]]

CREATE SCHEMA AUTHORIZATION rolename [schema_element [ ... ]]

更多信息,请参见CREATE SCHEMA

CREATE SEQUENCE

定义一个新的序列生成器。

CREATE [TEMPORARY | TEMP] SEQUENCE name
       [INCREMENT [BY] value] 
       [MINVALUE minvalue | NO MINVALUE] 
       [MAXVALUE maxvalue | NO MAXVALUE] 
       [START [ WITH ] start] 
       [CACHE cache] 
       [[NO] CYCLE] 
       [OWNED BY { table.column | NONE }]

更多信息,请参见CREATE SEQUENCE

CREATE TABLE

定义一个新的表。

CREATE [[GLOBAL | LOCAL] {TEMPORARY | TEMP}] TABLE table_name ( 
[ { column_name data_type [ DEFAULT default_expr ] 
   [column_constraint [ ... ]
[ ENCODING ( storage_directive [,...] ) ]
] 
   | table_constraint
   | LIKE other_table [{INCLUDING | EXCLUDING} 
                      {DEFAULTS | CONSTRAINTS}] ...}
   [, ... ] ]
   )
   [ INHERITS ( parent_table [, ... ] ) ]
   [ WITH ( storage_parameter=value [, ... ] )
   [ ON COMMIT {PRESERVE ROWS | DELETE ROWS | DROP} ]
   [ DISTRIBUTED BY (column, [ ... ] ) | DISTRIBUTED RANDOMLY ]
   [ PARTITION BY partition_type (column)
       [ SUBPARTITION BY partition_type (column) ] 
          [ SUBPARTITION TEMPLATE ( template_spec ) ]
       [...]
    ( partition_spec ) 
        | [ SUBPARTITION BY partition_type (column) ]
          [...]
    ( partition_spec
      [ ( subpartition_spec
           [(...)] 
         ) ] 
    )
说明

目前Serverless版本不支持WITH子句,系统会根据数据类型自动选择最优算法。

更多信息,请参见CREATE TABLE

CREATE TABLE AS

从查询的结果中定义一个新的表。

CREATE [ [GLOBAL | LOCAL] {TEMPORARY | TEMP} ] TABLE table_name
   [(column_name [, ...] )]
   [ WITH ( storage_parameter=value [, ... ] ) ]
   [ON COMMIT {PRESERVE ROWS | DELETE ROWS | DROP}]
   [TABLESPACE tablespace]
   AS query
   [DISTRIBUTED BY (column, [ ... ] ) | DISTRIBUTED RANDOMLY]

更多信息,请参见CREATE TABLE AS

CREATE TYPE

定义一个新的类型。

CREATE TYPE name AS ( attribute_name data_type [, ... ] )

CREATE TYPE name AS ENUM ( 'label' [, ... ] )

CREATE TYPE name (
    INPUT = input_function,
    OUTPUT = output_function
    [, RECEIVE = receive_function]
    [, SEND = send_function]
    [, TYPMOD_IN = type_modifier_input_function ]
    [, TYPMOD_OUT = type_modifier_output_function ]
    [, INTERNALLENGTH = {internallength | VARIABLE}]
    [, PASSEDBYVALUE]
    [, ALIGNMENT = alignment]
    [, STORAGE = storage]
    [, DEFAULT = default]
    [, ELEMENT = element]
    [, DELIMITER = delimiter] )

CREATE TYPE name

更多信息,请参见CREATE TYPE

CREATE USER

定义一个默认带有LOGIN权限的数据库角色。

CREATE USER name [ [WITH] option [ ... ] ]

更多信息,请参见CREATE USER

CREATE VIEW

定义一个新的视图。

CREATE [OR REPLACE] [TEMP | TEMPORARY] VIEW name
       [ ( column_name [, ...] ) ]
       AS query

更多信息,请参见CREATE VIEW

DEALLOCATE

取消分配一个预编译的语句。

DEALLOCATE [PREPARE] name

更多信息,请参见DEALLOCATE

DECLARE

定义一个游标。

DECLARE name [BINARY] [INSENSITIVE] [NO SCROLL] CURSOR 
     [{WITH | WITHOUT} HOLD] 
     FOR query [FOR READ ONLY]

更多信息,请参见DECLARE

DELETE

从表中删除行。

DELETE FROM [ONLY] table [[AS] alias]
      [USING usinglist]
      [WHERE condition | WHERE CURRENT OF cursor_name ]

更多信息,请参见DELETE

DROP AGGREGATE

删除聚集函数。

DROP AGGREGATE [IF EXISTS] name ( type [, ...] ) [CASCADE | RESTRICT]

更多信息,请参见DROP AGGREGATE

DROP CAST

删除一个CAST。

DROP CAST [IF EXISTS] (sourcetype AS targettype) [CASCADE | RESTRICT]

更多信息,请参见DROP CAST

DROP CONVERSION

删除一个转换。

DROP CONVERSION [IF EXISTS] name [CASCADE | RESTRICT]

更多信息,请参见DROP CONVERSION

DROP DATABASE

删除一个数据库。

DROP DATABASE [IF EXISTS] name

更多信息,请参见DROP DATABASE

DROP DOMAIN

删除一个域。

DROP DOMAIN [IF EXISTS] name [, ...]  [CASCADE | RESTRICT]

更多信息,请参见DROP DOMAIN

DROP EXTENSION

从数据库中删除一个扩展。

DROP EXTENSION [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

更多信息,请参见DROP EXTENSION

DROP EXTERNAL TABLE

删除一个外部表定义。

DROP EXTERNAL [WEB] TABLE [IF EXISTS] name [CASCADE | RESTRICT]

更多信息,请参见DROP EXTERNAL TABLE

DROP FUNCTION

删除一个函数。

DROP FUNCTION [IF EXISTS] name ( [ [argmode] [argname] argtype 
    [, ...] ] ) [CASCADE | RESTRICT]

更多信息,请参见DROP FUNCTION

DROP GROUP

删除一个数据库角色。

DROP GROUP [IF EXISTS] name [, ...]

更多信息,请参见DROP GROUP

DROP INDEX

删除一个索引。

DROP INDEX [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP INDEX

DROP LIBRARY

删除一个用户定义软件包。

DROP LIBRARY library_name

更多信息,请参见DROP LIBRARY

DROP OPERATOR

删除一个操作符。

DROP OPERATOR [IF EXISTS] name ( {lefttype | NONE} , 
    {righttype | NONE} ) [CASCADE | RESTRICT]

更多信息,请参见DROP OPERATOR

DROP OWNED

删除数据库角色所拥有的数据库对象。

DROP OWNED BY name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP OWNED

DROP RESOURCE QUEUE

删除一个资源队列。

DROP RESOURCE QUEUE queue_name

更多信息,请参见DROP RESOURCE QUEUE

DROP ROLE

删除一个数据库角色。

DROP ROLE [IF EXISTS] name [, ...]

更多信息,请参见DROP ROLE

DROP RULE

删除一个重写规则。

DROP RULE [IF EXISTS] name ON relation [CASCADE | RESTRICT]

更多信息,请参见DROP RULE

DROP SCHEMA

删除一个SCHEMA。

DROP SCHEMA [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP SCHEMA

DROP SEQUENCE

删除一个序列。

DROP SEQUENCE [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP SEQUENCE

DROP TABLE

删除一个表。

DROP TABLE [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP TABLE

DROP TYPE

删除一个数据类型。

DROP TYPE [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP TYPE

DROP USER

删除一个数据库角色。

DROP USER [IF EXISTS] name [, ...]

更多信息,请参见DROP USER

DROP VIEW

删除一个视图。

DROP VIEW [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见DROP VIEW

END

提交当前事务。

END [WORK | TRANSACTION]

更多信息,请参见END

EXECUTE

执行一个已经准备好的SQL语句。

EXECUTE name [ (parameter [, ...] ) ]

更多信息,请参见EXECUTE

EXPLAIN

展示语句的查询计划。

EXPLAIN [ANALYZE] [VERBOSE] statement

更多信息,请参见EXPLAIN

FETCH

使用游标获取查询结果的行。

FETCH [ forward_direction { FROM | IN } ] cursorname

更多信息,请参见FETCH

GRANT

定义一个访问权限。

GRANT { {SELECT | INSERT | UPDATE | DELETE | REFERENCES | 
TRIGGER | TRUNCATE } [,...] | ALL [PRIVILEGES] }
    ON [TABLE] tablename [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT { {USAGE | SELECT | UPDATE} [,...] | ALL [PRIVILEGES] }
    ON SEQUENCE sequencename [, ...]
    TO { rolename | PUBLIC } [, ...] [WITH GRANT OPTION]

GRANT { {CREATE | CONNECT | TEMPORARY | TEMP} [,...] | ALL 
[PRIVILEGES] }
    ON DATABASE dbname [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT { EXECUTE | ALL [PRIVILEGES] }
    ON FUNCTION funcname ( [ [argmode] [argname] argtype [, ...] 
] ) [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT { USAGE | ALL [PRIVILEGES] }
    ON LANGUAGE langname [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT { {CREATE | USAGE} [,...] | ALL [PRIVILEGES] }
    ON SCHEMA schemaname [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT { CREATE | ALL [PRIVILEGES] }
    ON TABLESPACE tablespacename [, ...]
    TO {rolename | PUBLIC} [, ...] [WITH GRANT OPTION]

GRANT parent_role [, ...] 
    TO member_role [, ...] [WITH ADMIN OPTION]

GRANT { SELECT | INSERT | ALL [PRIVILEGES] } 
    ON PROTOCOL protocolname
    TO username

更多信息,请参见GRANT

INSERT

在表中创建新的行。

INSERT INTO table [( column [, ...] )]
   {DEFAULT VALUES | VALUES ( {expression | DEFAULT} [, ...] ) 
   [, ...] | query}

更多信息,请参见INSERT

LOAD

加载或重新加载共享库文件。

LOAD 'filename'

更多信息,请参见LOAD

LOCK

锁住一张表。

LOCK [TABLE] name [, ...] [IN lockmode MODE] [NOWAIT]

更多信息,请参见LOCK

MOVE

放置一个游标。

MOVE [ forward_direction {FROM | IN} ] cursorname

更多信息,请参见MOVE

PREPARE

准备一个执行的语句。

PREPARE name [ (datatype [, ...] ) ] AS statement

更多信息,请参见PREPARE

REASSIGN OWNED

改变数据库角色所拥有的数据库对象的所有权。

REASSIGN OWNED BY old_role [, ...] TO new_role

更多信息,请参见REASSIGN OWNED

REINDEX

重新构建索引。

REINDEX {INDEX | TABLE | DATABASE | SYSTEM} name

更多信息,请参见REINDEX

RELEASE SAVEPOINT

销毁一个之前定义过的SAVEPOINT。

RELEASE [SAVEPOINT] savepoint_name

更多信息,请参见RELEASE SAVEPOINT

RESET

恢复系统配置参数的值为默认值。

RESET configuration_parameter

RESET ALL

更多信息,请参见RESET

REVOKE

撤销访问权限。

REVOKE [GRANT OPTION FOR] { {SELECT | INSERT | UPDATE | DELETE 
       | REFERENCES | TRIGGER | TRUNCATE } [,...] | ALL [PRIVILEGES] }
       ON [TABLE] tablename [, ...]
       FROM {rolename | PUBLIC} [, ...]
       [CASCADE | RESTRICT]

REVOKE [GRANT OPTION FOR] { {USAGE | SELECT | UPDATE} [,...] 
       | ALL [PRIVILEGES] }
       ON SEQUENCE sequencename [, ...]
       FROM { rolename | PUBLIC } [, ...]
       [CASCADE | RESTRICT]

REVOKE [GRANT OPTION FOR] { {CREATE | CONNECT 
       | TEMPORARY | TEMP} [,...] | ALL [PRIVILEGES] }
       ON DATABASE dbname [, ...]
       FROM {rolename | PUBLIC} [, ...]
       [CASCADE | RESTRICT]

REVOKE [GRANT OPTION FOR] {EXECUTE | ALL [PRIVILEGES]}
       ON FUNCTION funcname ( [[argmode] [argname] argtype
                              [, ...]] ) [, ...]
       FROM {rolename | PUBLIC} [, ...]
       [CASCADE | RESTRICT]

REVOKE [GRANT OPTION FOR] {USAGE | ALL [PRIVILEGES]}
       ON LANGUAGE langname [, ...]
       FROM {rolename | PUBLIC} [, ...]
       [ CASCADE | RESTRICT ]

REVOKE [GRANT OPTION FOR] { {CREATE | USAGE} [,...] 
       | ALL [PRIVILEGES] }
       ON SCHEMA schemaname [, ...]
       FROM {rolename | PUBLIC} [, ...]
       [CASCADE | RESTRICT]

REVOKE [GRANT OPTION FOR] { CREATE | ALL [PRIVILEGES] }
       ON TABLESPACE tablespacename [, ...]
       FROM { rolename | PUBLIC } [, ...]
       [CASCADE | RESTRICT]

REVOKE [ADMIN OPTION FOR] parent_role [, ...] 
       FROM member_role [, ...]
       [CASCADE | RESTRICT]

更多信息,请参见REVOKE

ROLLBACK

中止当前事务。

ROLLBACK [WORK | TRANSACTION]

更多信息,请参见ROLLBACK

ROLLBACK TO SAVEPOINT

将当前事务回滚到某个SAVEPOINT。

ROLLBACK [WORK | TRANSACTION] TO [SAVEPOINT] savepoint_name

更多信息,请参见ROLLBACK TO SAVEPOINT

SAVEPOINT

在当前事务定义一个新的savepoint。

SAVEPOINT savepoint_name

更多信息,请参见SAVEPOINT

SELECT

从表或者视图中检索行。

[ WITH with_query [, ...] ]
SELECT [ALL | DISTINCT [ON (expression [, ...])]]
  * | expression [[AS] output_name] [, ...]
  [FROM from_item [, ...]]
  [WHERE condition]
  [GROUP BY grouping_element [, ...]]
  [HAVING condition [, ...]]
  [WINDOW window_name AS (window_specification)]
  [{UNION | INTERSECT | EXCEPT} [ALL] select]
  [ORDER BY expression [ASC | DESC | USING operator] [NULLS {FIRST | LAST}] [, ...]]
  [LIMIT {count | ALL}]
  [OFFSET start]
  [FOR {UPDATE | SHARE} [OF table_name [, ...]] [NOWAIT] [...]]

更多信息,请参见SELECT

SELECT INTO

从查询结果中定义一个新的表。

[ WITH with_query [, ...] ]
SELECT [ALL | DISTINCT [ON ( expression [, ...] )]]
    * | expression [AS output_name] [, ...]
    INTO [TEMPORARY | TEMP] [TABLE] new_table
    [FROM from_item [, ...]]
    [WHERE condition]
    [GROUP BY expression [, ...]]
    [HAVING condition [, ...]]
    [{UNION | INTERSECT | EXCEPT} [ALL] select]
    [ORDER BY expression [ASC | DESC | USING operator] [NULLS {FIRST | LAST}] [, ...]]
    [LIMIT {count | ALL}]
    [OFFSET start]
    [FOR {UPDATE | SHARE} [OF table_name [, ...]] [NOWAIT] 
    [...]]

更多信息,请参见SELECT INTO

SET

改变数据库配置参数的值。

SET [SESSION | LOCAL] configuration_parameter {TO | =} value | 
    'value' | DEFAULT}

SET [SESSION | LOCAL] TIME ZONE {timezone | LOCAL | DEFAULT}

更多信息,请参见SET

SET ROLE

设置当前会话当前角色的标识符。

SET [SESSION | LOCAL] ROLE rolename

SET [SESSION | LOCAL] ROLE NONE

RESET ROLE

更多信息,请参见SET ROLE

SET SESSION AUTHORIZATION

设置会话角色标识符和当前会话当前角色的标识符。

SET [SESSION | LOCAL] SESSION AUTHORIZATION rolename

SET [SESSION | LOCAL] SESSION AUTHORIZATION DEFAULT

RESET SESSION AUTHORIZATION

更多信息,请参见SET SESSION AUTHORIZATION

SET TRANSACTION

设置当前事务的特征。

SET TRANSACTION [transaction_mode] [READ ONLY | READ WRITE]

SET SESSION CHARACTERISTICS AS TRANSACTION transaction_mode 
     [READ ONLY | READ WRITE]

更多信息,请参见SET TRANSACTION

SHOW

显示当前系统配置参数的值。

SHOW configuration_parameter

SHOW ALL

更多信息,请参见SHOW

START TRANSACTION

开始一个事务块。

START TRANSACTION [SERIALIZABLE | READ COMMITTED | READ UNCOMMITTED]
                  [READ WRITE | READ ONLY]

更多信息,请参见START TRANSACTION

TRUNCATE

清空表的所有行。

TRUNCATE [TABLE] name [, ...] [CASCADE | RESTRICT]

更多信息,请参见TRUNCATE

UPDATE

更新表的行。

UPDATE [ONLY] table [[AS] alias]
   SET {column = {expression | DEFAULT} |
   (column [, ...]) = ({expression | DEFAULT} [, ...])} [, ...]
   [FROM fromlist]
   [WHERE condition | WHERE CURRENT OF cursor_name ]

更多信息,请参见UPDATE

VACUUM

垃圾收集和选择性分析数据库。

VACUUM [FULL] [FREEZE] [VERBOSE] [table]

VACUUM [FULL] [FREEZE] [VERBOSE] ANALYZE
              [table [(column [, ...] )]]

更多信息,请参见VACUUM

VALUES

计算一组行。

VALUES ( expression [, ...] ) [, ...]
   [ORDER BY sort_expression [ASC | DESC | USING operator] [, ...]]
   [LIMIT {count | ALL}] [OFFSET start]

更多信息,请参见VALUES