select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Search PostgreSQL documentation

PG 18 · Browse by category, or enter a name or keyword

Popular entries9775
ExamplesManual ChaptersPG18Examples To create a transform for type hstore and language plpython3u, first set up the type and the language: CREATE TYPE hstore ...; CREATE EXTENSION plpython3u; Then create the necessary…Examples ExamplesManual ChaptersPG18Examples Execute the function check_account_update whenever a row of the table accounts is about to be updated: CREATE TRIGGER check_update BEFORE UPDATE ON accounts FOR EACH ROW EXECUTE FUN…Examples ExamplesManual ChaptersPG18Examples The following example command creates a Snowball-based dictionary with a nonstandard list of stop words. CREATE TEXT SEARCH DICTIONARY my_russian ( template = snowball, language = r…Examples ExamplesManual ChaptersPG18Examples This example creates a composite type and uses it in a function definition: CREATE TYPE compfoo AS (f1 int, f2 text); CREATE FUNCTION getfoo() RETURNS SETOF compfoo AS $$ SELECT foo…Examples ExamplesManual ChaptersPG18Examples Create a user mapping for user bob, server foo: CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');Examples ExamplesManual ChaptersPG18Examples Create a view consisting of all comedy films: CREATE VIEW comedies AS SELECT * FROM films WHERE kind = 'Comedy'; This will create a view containing the columns that are in the film …Examples ExamplesManual ChaptersPG18Examples To declare a cursor: DECLARE liahona CURSOR FOR SELECT * FROM films; See FETCH for more examples of cursor usage.Examples ExamplesManual ChaptersPG18Examples Delete all films but musicals: DELETE FROM films WHERE kind <> 'Musical'; Clear the table films: DELETE FROM films; Delete completed tasks, returning full details of the deleted row…Examples ExamplesManual ChaptersPG18Examples Grant all privileges on all views in schema public to role webuser: DO $$DECLARE r record; BEGIN FOR r IN SELECT table_schema, table_name FROM information_schema.tables WHERE table_…Examples ExamplesManual ChaptersPG18Examples Drop the access method heptree: DROP ACCESS METHOD heptree;Examples ExamplesManual ChaptersPG18Examples To remove the aggregate function myavg for type integer: DROP AGGREGATE myavg(integer); To remove the hypothetical-set aggregate function myrank, which takes an arbitrary list of or…Examples ExamplesManual ChaptersPG18Examples To drop the cast from type text to type int: DROP CAST (text AS int);Examples ExamplesManual ChaptersPG18Examples To drop the collation named german: DROP COLLATION german;Examples ExamplesManual ChaptersPG18Examples To drop the conversion named myname: DROP CONVERSION myname;Examples ExamplesManual ChaptersPG18Examples To remove the domain box: DROP DOMAIN box;Examples ExamplesManual ChaptersPG18Examples Destroy the trigger snitch: DROP EVENT TRIGGER snitch;Examples ExamplesManual ChaptersPG18Examples To remove the extension hstore from the current database: DROP EXTENSION hstore; This command will fail if any of hstore's objects are in use in the database, for example if any tab…Examples ExamplesManual ChaptersPG18Examples Drop the foreign-data wrapper dbi: DROP FOREIGN DATA WRAPPER dbi;Examples ExamplesManual ChaptersPG18Examples To destroy two foreign tables, films and distributors: DROP FOREIGN TABLE films, distributors;Examples ExamplesManual ChaptersPG18Examples This command removes the square root function: DROP FUNCTION sqrt(integer); Drop multiple functions in one command: DROP FUNCTION sqrt(integer), sqrt(bigint); If the function name i…Examples ExamplesManual ChaptersPG18Examples This command will remove the index title_idx: DROP INDEX title_idx;Examples ExamplesManual ChaptersPG18Examples This command removes the procedural language plsample: DROP LANGUAGE plsample;Examples ExamplesManual ChaptersPG18Examples This command will remove the materialized view called order_summary: DROP MATERIALIZED VIEW order_summary;Examples ExamplesManual ChaptersPG18Examples Remove the B-tree operator class widget_ops: DROP OPERATOR CLASS widget_ops USING btree; This command will not succeed if there are any existing indexes that use the operator class.…Examples ExamplesManual ChaptersPG18Examples Remove the power operator a^b for type integer: DROP OPERATOR ^ (integer, integer); Remove the bitwise-complement prefix operator ~b for type bit: DROP OPERATOR ~ (none, bit); Remov…Examples ExamplesManual ChaptersPG18Examples Remove the B-tree operator family float_ops: DROP OPERATOR FAMILY float_ops USING btree; This command will not succeed if there are any existing indexes that use operator classes wi…Examples ExamplesManual ChaptersPG18Examples To drop the policy called p1 on the table named my_table: DROP POLICY p1 ON my_table;Examples ExamplesManual ChaptersPG18Examples If there is only one procedure do_db_maintenance, this command is sufficient to drop it: DROP PROCEDURE do_db_maintenance; Given this procedure definition: CREATE PROCEDURE do_db_ma…Examples ExamplesManual ChaptersPG18Examples Drop a publication: DROP PUBLICATION mypublication;Examples ExamplesManual ChaptersPG18Examples To drop a role: DROP ROLE jonathan;Examples ExamplesManual ChaptersPG18Examples To drop the routine foo for type integer: DROP ROUTINE foo(integer); This command will work independent of whether foo is an aggregate, function, or procedure.Examples ExamplesManual ChaptersPG18Examples To drop the rewrite rule newrule: DROP RULE newrule ON mytable;Examples ExamplesManual ChaptersPG18Examples To remove schema mystuff from the database, along with everything it contains: DROP SCHEMA mystuff CASCADE;Examples ExamplesManual ChaptersPG18Examples To remove the sequence serial: DROP SEQUENCE serial;Examples ExamplesManual ChaptersPG18Examples Drop a server foo if it exists: DROP SERVER IF EXISTS foo;Examples ExamplesManual ChaptersPG18Examples To destroy two statistics objects in different schemas, without failing if they don't exist: DROP STATISTICS IF EXISTS accounting.users_uid_creation, public.grants_user_role;Examples ExamplesManual ChaptersPG18Examples Drop a subscription: DROP SUBSCRIPTION mysub;Examples ExamplesManual ChaptersPG18Examples To destroy two tables, films and distributors: DROP TABLE films, distributors;Examples ExamplesManual ChaptersPG18Examples To remove tablespace mystuff from the system: DROP TABLESPACE mystuff;Examples ExamplesManual ChaptersPG18Examples To drop the transform for type hstore and language plpython3u: DROP TRANSFORM FOR hstore LANGUAGE plpython3u;Examples
More results

Find definitions in the PostgreSQL manuals, reference library, and extension catalogue.

pg17: choose a version ex: extensions only select open