本文介紹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 TRIGGER
定義一個新的觸發器。
CREATE TRIGGER name {BEFORE | AFTER} {event [OR ...]}
ON table [ FOR [EACH] {ROW | STATEMENT} ]
EXECUTE PROCEDURE funcname ( arguments )
更多資訊,請參見CREATE TRIGGER。
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。