2e6d18e7dc
* feat(pgsql: upgrade keywords and refresh them to parser file): pgsql * feat(pgsql: check create table's syntax): pgsql * feat(pgsql: check and update drop syntax): pgsql: check and update drop syntax * feat: pgsql: check create's sql syntax and update g4 file * feat: pgsql:complete other's sql and syntax except select, insert, drop * feat: pgsql: update create, delete, insert, select, update and others' syntax * test: pgsql: update alter's sql * feat: pgsql: update syntax g4 file * feat: pgsql: upgrade keywords to without '_P' in lexer and parser file * docs: pgsql: update copyright and Reference of parser and lexer --------- Co-authored-by: zhaoge <>
288 lines
7.7 KiB
SQL
288 lines
7.7 KiB
SQL
-- ABORT
|
||
ABORT WORK;
|
||
ABORT TRANSACTION;
|
||
|
||
-- ANALYZE
|
||
ANALYZE VERBOSE table_name ( column_name, column_name2);
|
||
ANALYZE;
|
||
|
||
-- BEGIN
|
||
BEGIN WORK ISOLATION LEVEL READ UNCOMMITTED
|
||
READ WRITE
|
||
NOT DEFERRABLE;
|
||
-- CHECKPOINT
|
||
CHECKPOINT;
|
||
|
||
-- CLUSTER
|
||
CLUSTER VERBOSE table_name USING index_name;
|
||
CLUSTER VERBOSE;
|
||
|
||
-- CLOSE
|
||
CLOSE ALL;
|
||
CLOSE name_2;
|
||
|
||
-- COMMENT
|
||
COMMENT ON
|
||
AGGREGATE agg_name (agg_type, agg_type2) IS 'text';
|
||
COMMENT ON CAST (source_type AS target_type) IS 'text';
|
||
COMMENT ON COLLATION object_name IS 'text';
|
||
COMMENT ON COLUMN relation_name.column_name IS 'text'
|
||
COMMENT ON CONVERSION object_name IS 'text';
|
||
COMMENT ON CONSTRAINT constraint_name ON table_name IS 'text';
|
||
COMMENT ON DATABASE object_name IS 'text';
|
||
COMMENT ON DOMAIN object_name IS 'text';
|
||
COMMENT ON EXTENSION object_name IS 'text';
|
||
COMMENT ON EVENT TRIGGER object_name IS 'text';
|
||
COMMENT ON FOREIGN DATA WRAPPER object_name IS 'text';
|
||
COMMENT ON FOREIGN TABLE object_name IS 'text';
|
||
COMMENT ON FUNCTION function_name ( INOUT argname timestamp) IS 'text';
|
||
COMMENT ON INDEX object_name IS 'text';
|
||
COMMENT ON LARGE OBJECT 346344 IS 'text';
|
||
COMMENT ON MATERIALIZED VIEW object_name IS 'text';
|
||
COMMENT ON OPERATOR -(int, NONE) IS 'text';
|
||
COMMENT ON OPERATOR CLASS object_name USING index_method IS 'text';
|
||
COMMENT ON OPERATOR FAMILY object_name USING index_method IS 'text';
|
||
COMMENT ON PROCEDURAL LANGUAGE object_name IS 'text';
|
||
COMMENT ON ROLE object_name IS 'text';
|
||
COMMENT ON RULE rule_name ON table_name IS 'text';
|
||
COMMENT ON SCHEMA object_name IS 'text';
|
||
COMMENT ON SEQUENCE object_name IS 'text';
|
||
COMMENT ON SERVER object_name IS 'text';
|
||
COMMENT ON TABLE object_name IS 'text';
|
||
COMMENT ON TABLESPACE object_name IS 'text';
|
||
COMMENT ON TEXT SEARCH CONFIGURATION object_name IS 'text';
|
||
COMMENT ON TEXT SEARCH DICTIONARY object_name IS 'text';
|
||
COMMENT ON TEXT SEARCH PARSER object_name IS 'text';
|
||
COMMENT ON TEXT SEARCH TEMPLATE object_name IS 'text';
|
||
COMMENT ON TRIGGER trigger_name ON table_name IS 'text';
|
||
COMMENT ON TYPE object_name IS 'text';
|
||
COMMENT ON VIEW object_name IS 'text';
|
||
|
||
-- COMMIT
|
||
COMMIT TRANSACTION;
|
||
COMMIT WORK;
|
||
|
||
-- COMMIT PREPARED
|
||
COMMIT PREPARED 'foobar';
|
||
|
||
-- COPY
|
||
COPY table_name ( column_name, column_name2)
|
||
FROM PROGRAM 'command'
|
||
WITH ( FORMAT format_name);
|
||
COPY (SELECT * FROM td)
|
||
TO STDOUT
|
||
WITH (DELIMITER 'delimiter_character');
|
||
|
||
|
||
-- DEALLOCATE
|
||
DEALLOCATE PREPARE name;
|
||
DEALLOCATE PREPARE ALL;
|
||
|
||
-- DECLARE
|
||
DECLARE name BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR
|
||
SELECT
|
||
*
|
||
FROM
|
||
tb;
|
||
|
||
DECLARE name CURSOR FOR
|
||
SELECT
|
||
*
|
||
FROM
|
||
abs;
|
||
|
||
-- DISCARD
|
||
DISCARD TEMPORARY;
|
||
DISCARD PLANS;
|
||
DISCARD ALL;
|
||
DISCARD TEMP;
|
||
|
||
-- DO
|
||
DO LANGUAGE lang_name '$$DECLARE' r record;
|
||
DO '$$DECLARE' r record;
|
||
|
||
-- END
|
||
END TRANSACTION;
|
||
END WORK;
|
||
|
||
-- EXECUTE
|
||
EXECUTE name ( parameter, parameter2);
|
||
|
||
-- EXPLAIN
|
||
EXPLAIN ( ANALYZE 'true',VERBOSE true, COSTS TRUE, FORMAT TEXT) SELECT * FROM no_nw;
|
||
EXPLAIN ANALYZE VERBOSE SELECT * FROM no_nw;
|
||
|
||
-- FETCH
|
||
FETCH NEXT FROM cursor_name;
|
||
|
||
-- GRANT
|
||
GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER
|
||
ON TABLE table_name, table_name2
|
||
TO GROUP role_name,PUBLIC WITH GRANT OPTION;
|
||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name, schema_name2 TO PUBLIC;
|
||
GRANT SELECT( column_name, column_name2), INSERT( column_name, column_name2), UPDATE( column_name, column_name2), REFERENCES ( column_name, column_name2)
|
||
ON TABLE table_name
|
||
TO GROUP role_name WITH GRANT OPTION;
|
||
GRANT ALL PRIVILEGES ( column_name, column_name2) ON table_name TO role_name;
|
||
GRANT USAGE, SELECT, UPDATE
|
||
ON SEQUENCE sequence_name
|
||
TO GROUP role_name, PUBLIC WITH GRANT OPTION;
|
||
GRANT ALL PRIVILEGES
|
||
ON ALL SEQUENCES IN SCHEMA schema_name
|
||
TO PUBLIC WITH GRANT OPTION;
|
||
GRANT CREATE, CONNECT, TEMPORARY, TEMP
|
||
ON DATABASE database_name
|
||
TO GROUP role_name, PUBLIC WITH GRANT OPTION;
|
||
GRANT role_name TO role_name;
|
||
|
||
|
||
-- LISTEN
|
||
LISTEN channel;
|
||
|
||
-- LOAD
|
||
LOAD 'filename';
|
||
|
||
-- LOCK
|
||
-- lockmode:ACCESS SHARE | ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE
|
||
-- | SHARE | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE
|
||
LOCK TABLE ONLY name * IN ACCESS SHARE MODE NOWAIT;
|
||
|
||
-- MOVE
|
||
MOVE NEXT FROM cursor_name;
|
||
|
||
-- NOTIFY
|
||
NOTIFY virtual, 'This is the payload';
|
||
|
||
-- PREPARE
|
||
PREPARE name ( int, numeric) AS INSERT INTO foo VALUES($1, $2, $3, $4);
|
||
|
||
-- PREPARE TRANSACTION
|
||
PREPARE TRANSACTION 'foobar';
|
||
|
||
-- REASSIGN OWNED
|
||
REASSIGN OWNED BY old_role TO new_role;
|
||
|
||
-- REFRESH MATERIALIZED VIEW
|
||
REFRESH MATERIALIZED VIEW name WITH NO DATA;
|
||
|
||
-- REINDEX
|
||
REINDEX DATABASE name FORCE;
|
||
REINDEX TABLE name;
|
||
REINDEX INDEX name;
|
||
REINDEX SYSTEM name;
|
||
|
||
-- RELEASE SAVEPOINT
|
||
RELEASE SAVEPOINT savepoint_name;
|
||
|
||
-- RESET
|
||
RESET configuration_parameter;
|
||
RESET ALL;
|
||
|
||
-- REVOKE
|
||
REVOKE GRANT OPTION FOR
|
||
REFERENCES, CREATE
|
||
ON TABLE table_name
|
||
FROM GROUP role_name, PUBLIC
|
||
RESTRICT;
|
||
REVOKE ALL PRIVILEGES ON accounts FROM PUBLIC;
|
||
REVOKE CREATE ON SCHEMA public_name FROM PUBLIC;
|
||
|
||
-- ROLLBACK
|
||
ROLLBACK TRANSACTION;
|
||
ROLLBACK WORK;
|
||
|
||
-- ROLLBACK PREPARED
|
||
ROLLBACK PREPARED 'foobar';
|
||
|
||
-- ROLLBACK TO SAVEPOINT
|
||
ROLLBACK TRANSACTION TO SAVEPOINT savepoint_name;
|
||
ROLLBACK WORK TO SAVEPOINT savepoint_name;
|
||
ROLLBACK TO savepoint_name;
|
||
|
||
-- SAVEPOINT
|
||
SAVEPOINT savepoint_name;
|
||
|
||
-- SECURITY LABEL
|
||
SECURITY LABEL FOR provider ON TABLE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON COLUMN table_name.column_name IS 'label';
|
||
SECURITY LABEL FOR provider ON AGGREGATE agg_name (agg_type, agg_type2) IS 'label';
|
||
SECURITY LABEL FOR provider ON DATABASE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON DOMAIN object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON EVENT TRIGGER object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON FOREIGN TABLE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON FUNCTION function_name ( VARIADIC arg_name timestamp) IS 'label';
|
||
SECURITY LABEL FOR provider ON LARGE OBJECT 2432 IS 'label';
|
||
SECURITY LABEL FOR provider ON MATERIALIZED VIEW object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON PROCEDURAL LANGUAGE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON ROLE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON SCHEMA object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON SEQUENCE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON TABLESPACE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON TYPE object_name IS 'label';
|
||
SECURITY LABEL FOR provider ON VIEW object_name IS 'label';
|
||
|
||
-- SET
|
||
SET SESSION configuration_parameter TO DEFAULT;
|
||
SET LOCAL TIME ZONE LOCAL;
|
||
|
||
-- SET CONSTRAINTS
|
||
SET CONSTRAINTS ALL IMMEDIATE;
|
||
SET CONSTRAINTS name1, name2 DEFERRED;
|
||
|
||
-- SET ROLE
|
||
SET SESSION ROLE role_name;
|
||
SET LOCAL ROLE NONE;
|
||
RESET ROLE;
|
||
|
||
-- SET SESSION AUTHORIZATION
|
||
SET SESSION SESSION AUTHORIZATION user_name;
|
||
SET LOCAL SESSION AUTHORIZATION DEFAULT;
|
||
RESET SESSION AUTHORIZATION;
|
||
|
||
-- SET TRANSACTION
|
||
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
|
||
READ WRITE
|
||
NOT DEFERRABLE;
|
||
SET TRANSACTION SNAPSHOT '000003A1-1';
|
||
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY DEFERRABLE;
|
||
|
||
-- SHOW
|
||
SHOW name;
|
||
SHOW ALL;
|
||
|
||
-- START TRANSACTION
|
||
START TRANSACTION ISOLATION LEVEL SERIALIZABLE
|
||
READ WRITE
|
||
NOT DEFERRABLE, ISOLATION LEVEL REPEATABLE READ READ ONLY DEFERRABLE;
|
||
START TRANSACTION;
|
||
|
||
-- TRUNCATE
|
||
TRUNCATE TABLE ONLY name
|
||
RESTART IDENTITY CASCADE;
|
||
TRUNCATE TABLE ONLY name
|
||
CONTINUE IDENTITY RESTRICT;
|
||
TRUNCATE name;
|
||
|
||
-- UNLISTEN
|
||
UNLISTEN *;
|
||
UNLISTEN channel;
|
||
|
||
-- VACUUM
|
||
VACUUM ( FULL, FREEZE, VERBOSE, ANALYZE) table_name (column_name, column_name2);
|
||
VACUUM FULL FREEZE VERBOSE table_name;
|
||
VACUUM FULL FREEZE VERBOSE ANALYZE table_name (column_name,column_name2);
|
||
VACUUM ANALYZE;
|
||
ANALYZE;
|
||
|
||
-- VALUES
|
||
VALUES (1, '3'), (3, 'sdsd')
|
||
ORDER BY sort_expression ASC
|
||
LIMIT 20
|
||
OFFSET 324 ROW
|
||
FETCH NEXT 343 ROWS ONLY ;
|
||
VALUES (1, '3'), (3, 'sdsd');
|
||
|
||
-- Caveats
|
||
ANALYZE measurement;
|
||
|