{
    "mode": "man",
    "parameter": "COMMENT",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/COMMENT/7/json",
    "generated": "2026-06-16T22:21:02Z",
    "synopsis": "COMMENT ON\n{\nACCESS METHOD objectname |\nAGGREGATE aggregatename ( aggregatesignature ) |\nCAST (sourcetype AS targettype) |\nCOLLATION objectname |\nCOLUMN relationname.columnname |\nCONSTRAINT constraintname ON tablename |\nCONSTRAINT constraintname ON DOMAIN domainname |\nCONVERSION objectname |\nDATABASE objectname |\nDOMAIN objectname |\nEXTENSION objectname |\nEVENT TRIGGER objectname |\nFOREIGN DATA WRAPPER objectname |\nFOREIGN TABLE objectname |\nFUNCTION functionname [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nINDEX objectname |\nLARGE OBJECT largeobjectoid |\nMATERIALIZED VIEW objectname |\nOPERATOR operatorname (lefttype, righttype) |\nOPERATOR CLASS objectname USING indexmethod |\nOPERATOR FAMILY objectname USING indexmethod |\nPOLICY policyname ON tablename |\n[ PROCEDURAL ] LANGUAGE objectname |\nPROCEDURE procedurename [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nPUBLICATION objectname |\nROLE objectname |\nROUTINE routinename [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nRULE rulename ON tablename |\nSCHEMA objectname |\nSEQUENCE objectname |\nSERVER objectname |\nSTATISTICS objectname |\nSUBSCRIPTION objectname |\nTABLE objectname |\nTABLESPACE objectname |\nTEXT SEARCH CONFIGURATION objectname |\nTEXT SEARCH DICTIONARY objectname |\nTEXT SEARCH PARSER objectname |\nTEXT SEARCH TEMPLATE objectname |\nTRANSFORM FOR typename LANGUAGE langname |\nTRIGGER triggername ON tablename |\nTYPE objectname |\nVIEW objectname\n} IS { stringliteral | NULL }\nwhere aggregatesignature is:\n* |\n[ argmode ] [ argname ] argtype [ , ... ] |\n[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]",
    "sections": {
        "NAME": {
            "content": "COMMENT - define or change the comment of an object\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "COMMENT ON\n{\nACCESS METHOD objectname |\nAGGREGATE aggregatename ( aggregatesignature ) |\nCAST (sourcetype AS targettype) |\nCOLLATION objectname |\nCOLUMN relationname.columnname |\nCONSTRAINT constraintname ON tablename |\nCONSTRAINT constraintname ON DOMAIN domainname |\nCONVERSION objectname |\nDATABASE objectname |\nDOMAIN objectname |\nEXTENSION objectname |\nEVENT TRIGGER objectname |\nFOREIGN DATA WRAPPER objectname |\nFOREIGN TABLE objectname |\nFUNCTION functionname [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nINDEX objectname |\nLARGE OBJECT largeobjectoid |\nMATERIALIZED VIEW objectname |\nOPERATOR operatorname (lefttype, righttype) |\nOPERATOR CLASS objectname USING indexmethod |\nOPERATOR FAMILY objectname USING indexmethod |\nPOLICY policyname ON tablename |\n[ PROCEDURAL ] LANGUAGE objectname |\nPROCEDURE procedurename [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nPUBLICATION objectname |\nROLE objectname |\nROUTINE routinename [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] |\nRULE rulename ON tablename |\nSCHEMA objectname |\nSEQUENCE objectname |\nSERVER objectname |\nSTATISTICS objectname |\nSUBSCRIPTION objectname |\nTABLE objectname |\nTABLESPACE objectname |\nTEXT SEARCH CONFIGURATION objectname |\nTEXT SEARCH DICTIONARY objectname |\nTEXT SEARCH PARSER objectname |\nTEXT SEARCH TEMPLATE objectname |\nTRANSFORM FOR typename LANGUAGE langname |\nTRIGGER triggername ON tablename |\nTYPE objectname |\nVIEW objectname\n} IS { stringliteral | NULL }\n\nwhere aggregatesignature is:\n\n* |\n[ argmode ] [ argname ] argtype [ , ... ] |\n[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "COMMENT stores, replaces, or removes the comment on a database object.\n\nOnly one comment string is stored for each object. Issuing a new COMMENT command for the same\nobject replaces the existing comment. Specifying NULL or an empty string ('') removes the\ncomment. Comments are automatically dropped when their object is dropped.\n\nA SHARE UPDATE EXCLUSIVE lock is acquired on the object to be commented.\n\nFor most kinds of object, only the object's owner can set the comment. Roles don't have\nowners, so the rule for COMMENT ON ROLE is that you must be superuser to comment on a\nsuperuser role, or have the CREATEROLE privilege to comment on non-superuser roles. Likewise,\naccess methods don't have owners either; you must be superuser to comment on an access\nmethod. Of course, a superuser can comment on anything.\n\nComments can be viewed using psql's \\d family of commands. Other user interfaces to retrieve\ncomments can be built atop the same built-in functions that psql uses, namely\nobjdescription, coldescription, and shobjdescription (see Table 9.75).\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "objectname\nrelationname.columnname\naggregatename\nconstraintname\nfunctionname\noperatorname\npolicyname\nprocedurename\nroutinename\nrulename\ntriggername\nThe name of the object to be commented. Names of objects that reside in schemas (tables,\nfunctions, etc.) can be schema-qualified. When commenting on a column, relationname must\nrefer to a table, view, composite type, or foreign table.\n\ntablename\ndomainname\nWhen creating a comment on a constraint, a trigger, a rule or a policy these parameters\nspecify the name of the table or domain on which that object is defined.\n\nsourcetype\nThe name of the source data type of the cast.\n\ntargettype\nThe name of the target data type of the cast.\n\nargmode\nThe mode of a function, procedure, or aggregate argument: IN, OUT, INOUT, or VARIADIC. If\nomitted, the default is IN. Note that COMMENT does not actually pay any attention to OUT\narguments, since only the input arguments are needed to determine the function's\nidentity. So it is sufficient to list the IN, INOUT, and VARIADIC arguments.\n\nargname\nThe name of a function, procedure, or aggregate argument. Note that COMMENT does not\nactually pay any attention to argument names, since only the argument data types are\nneeded to determine the function's identity.\n\nargtype\nThe data type of a function, procedure, or aggregate argument.\n\nlargeobjectoid\nThe OID of the large object.\n\nlefttype\nrighttype\nThe data type(s) of the operator's arguments (optionally schema-qualified). Write NONE\nfor the missing argument of a prefix operator.\n\nPROCEDURAL\nThis is a noise word.\n\ntypename\nThe name of the data type of the transform.\n\nlangname\nThe name of the language of the transform.\n\nstringliteral\nThe new comment contents, written as a string literal. An empty string ('') removes the\ncomment.\n\nNULL\nWrite NULL to remove the comment.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "There is presently no security mechanism for viewing comments: any user connected to a\ndatabase can see all the comments for objects in that database. For shared objects such as\ndatabases, roles, and tablespaces, comments are stored globally so any user connected to any\ndatabase in the cluster can see all the comments for shared objects. Therefore, don't put\nsecurity-critical information in comments.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Attach a comment to the table mytable:\n\nCOMMENT ON TABLE mytable IS 'This is my table.';\n\nRemove it again:\n\nCOMMENT ON TABLE mytable IS NULL;\n\nSome more examples:\n\nCOMMENT ON ACCESS METHOD gin IS 'GIN index access method';\nCOMMENT ON AGGREGATE myaggregate (double precision) IS 'Computes sample variance';\nCOMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';\nCOMMENT ON COLLATION \"frCA\" IS 'Canadian French';\nCOMMENT ON COLUMN mytable.mycolumn IS 'Employee ID number';\nCOMMENT ON CONVERSION myconv IS 'Conversion to UTF8';\nCOMMENT ON CONSTRAINT barcolcons ON bar IS 'Constrains column col';\nCOMMENT ON CONSTRAINT domcolconstr ON DOMAIN dom IS 'Constrains col of domain';\nCOMMENT ON DATABASE mydatabase IS 'Development Database';\nCOMMENT ON DOMAIN mydomain IS 'Email Address Domain';\nCOMMENT ON EVENT TRIGGER abortddl IS 'Aborts all DDL commands';\nCOMMENT ON EXTENSION hstore IS 'implements the hstore data type';\nCOMMENT ON FOREIGN DATA WRAPPER mywrapper IS 'my foreign data wrapper';\nCOMMENT ON FOREIGN TABLE myforeigntable IS 'Employee Information in other database';\nCOMMENT ON FUNCTION myfunction (timestamp) IS 'Returns Roman Numeral';\nCOMMENT ON INDEX myindex IS 'Enforces uniqueness on employee ID';\nCOMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';\nCOMMENT ON LARGE OBJECT 346344 IS 'Planning document';\nCOMMENT ON MATERIALIZED VIEW mymatview IS 'Summary of order history';\nCOMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';\nCOMMENT ON OPERATOR - (NONE, integer) IS 'Unary minus';\nCOMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';\nCOMMENT ON OPERATOR FAMILY integerops USING btree IS 'all integer operators for btrees';\nCOMMENT ON POLICY mypolicy ON mytable IS 'Filter rows by users';\nCOMMENT ON PROCEDURE myproc (integer, integer) IS 'Runs a report';\nCOMMENT ON PUBLICATION alltables IS 'Publishes all operations on all tables';\nCOMMENT ON ROLE myrole IS 'Administration group for finance tables';\nCOMMENT ON ROUTINE myroutine (integer, integer) IS 'Runs a routine (which is a function or procedure)';\nCOMMENT ON RULE myrule ON mytable IS 'Logs updates of employee records';\nCOMMENT ON SCHEMA myschema IS 'Departmental data';\nCOMMENT ON SEQUENCE mysequence IS 'Used to generate primary keys';\nCOMMENT ON SERVER myserver IS 'my foreign server';\nCOMMENT ON STATISTICS mystatistics IS 'Improves planner row estimations';\nCOMMENT ON SUBSCRIPTION alltables IS 'Subscription for all operations on all tables';\nCOMMENT ON TABLE myschema.mytable IS 'Employee Information';\nCOMMENT ON TABLESPACE mytablespace IS 'Tablespace for indexes';\nCOMMENT ON TEXT SEARCH CONFIGURATION myconfig IS 'Special word filtering';\nCOMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for Swedish language';\nCOMMENT ON TEXT SEARCH PARSER myparser IS 'Splits text into words';\nCOMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer';\nCOMMENT ON TRANSFORM FOR hstore LANGUAGE plpythonu IS 'Transform between hstore and Python dict';\nCOMMENT ON TRIGGER mytrigger ON mytable IS 'Used for RI';\nCOMMENT ON TYPE complex IS 'Complex number data type';\nCOMMENT ON VIEW myview IS 'View of departmental costs';\nCOMMENT ON VIEW myview IS NULL;\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "There is no COMMENT command in the SQL standard.\n\n\n\nPostgreSQL 14.23                                2026                                      COMMENT(7)",
            "subsections": []
        }
    },
    "summary": "COMMENT - define or change the comment of an object",
    "flags": [],
    "examples": [
        "Attach a comment to the table mytable:",
        "COMMENT ON TABLE mytable IS 'This is my table.';",
        "Remove it again:",
        "COMMENT ON TABLE mytable IS NULL;",
        "Some more examples:",
        "COMMENT ON ACCESS METHOD gin IS 'GIN index access method';",
        "COMMENT ON AGGREGATE myaggregate (double precision) IS 'Computes sample variance';",
        "COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';",
        "COMMENT ON COLLATION \"frCA\" IS 'Canadian French';",
        "COMMENT ON COLUMN mytable.mycolumn IS 'Employee ID number';",
        "COMMENT ON CONVERSION myconv IS 'Conversion to UTF8';",
        "COMMENT ON CONSTRAINT barcolcons ON bar IS 'Constrains column col';",
        "COMMENT ON CONSTRAINT domcolconstr ON DOMAIN dom IS 'Constrains col of domain';",
        "COMMENT ON DATABASE mydatabase IS 'Development Database';",
        "COMMENT ON DOMAIN mydomain IS 'Email Address Domain';",
        "COMMENT ON EVENT TRIGGER abortddl IS 'Aborts all DDL commands';",
        "COMMENT ON EXTENSION hstore IS 'implements the hstore data type';",
        "COMMENT ON FOREIGN DATA WRAPPER mywrapper IS 'my foreign data wrapper';",
        "COMMENT ON FOREIGN TABLE myforeigntable IS 'Employee Information in other database';",
        "COMMENT ON FUNCTION myfunction (timestamp) IS 'Returns Roman Numeral';",
        "COMMENT ON INDEX myindex IS 'Enforces uniqueness on employee ID';",
        "COMMENT ON LANGUAGE plpython IS 'Python support for stored procedures';",
        "COMMENT ON LARGE OBJECT 346344 IS 'Planning document';",
        "COMMENT ON MATERIALIZED VIEW mymatview IS 'Summary of order history';",
        "COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';",
        "COMMENT ON OPERATOR - (NONE, integer) IS 'Unary minus';",
        "COMMENT ON OPERATOR CLASS int4ops USING btree IS '4 byte integer operators for btrees';",
        "COMMENT ON OPERATOR FAMILY integerops USING btree IS 'all integer operators for btrees';",
        "COMMENT ON POLICY mypolicy ON mytable IS 'Filter rows by users';",
        "COMMENT ON PROCEDURE myproc (integer, integer) IS 'Runs a report';",
        "COMMENT ON PUBLICATION alltables IS 'Publishes all operations on all tables';",
        "COMMENT ON ROLE myrole IS 'Administration group for finance tables';",
        "COMMENT ON ROUTINE myroutine (integer, integer) IS 'Runs a routine (which is a function or procedure)';",
        "COMMENT ON RULE myrule ON mytable IS 'Logs updates of employee records';",
        "COMMENT ON SCHEMA myschema IS 'Departmental data';",
        "COMMENT ON SEQUENCE mysequence IS 'Used to generate primary keys';",
        "COMMENT ON SERVER myserver IS 'my foreign server';",
        "COMMENT ON STATISTICS mystatistics IS 'Improves planner row estimations';",
        "COMMENT ON SUBSCRIPTION alltables IS 'Subscription for all operations on all tables';",
        "COMMENT ON TABLE myschema.mytable IS 'Employee Information';",
        "COMMENT ON TABLESPACE mytablespace IS 'Tablespace for indexes';",
        "COMMENT ON TEXT SEARCH CONFIGURATION myconfig IS 'Special word filtering';",
        "COMMENT ON TEXT SEARCH DICTIONARY swedish IS 'Snowball stemmer for Swedish language';",
        "COMMENT ON TEXT SEARCH PARSER myparser IS 'Splits text into words';",
        "COMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer';",
        "COMMENT ON TRANSFORM FOR hstore LANGUAGE plpythonu IS 'Transform between hstore and Python dict';",
        "COMMENT ON TRIGGER mytrigger ON mytable IS 'Used for RI';",
        "COMMENT ON TYPE complex IS 'Complex number data type';",
        "COMMENT ON VIEW myview IS 'View of departmental costs';",
        "COMMENT ON VIEW myview IS NULL;"
    ],
    "see_also": []
}