Bug #52429 Allow COMMENTs in VIEWs as it exists for TABLEs

Submitted: 29 Mar 2010 9:38 Modified: 29 Mar 2010 9:43
Reporter: Leandro Morgado Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[29 Mar 2010 9:38] Leandro Morgado
Description:
When using tables, we can create both table level and column level comments:

mysql> CREATE TABLE `t1` (   `a` bigint(20) unsigned DEFAULT '1' COMMENT 'my column' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT 'mytable';
Query OK, 0 rows affected (0.08 sec)

mysql> SHOW CREATE TABLE t1;
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                           |
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` bigint(20) unsigned DEFAULT '1' COMMENT 'my column'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='mytable' |
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

How to repeat:
However, this does not work for VIEWs:

mysql> CREATE VIEW v AS SELECT * FROM t1 COMMENT 'mytable';ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''mytable'' at line 1

mysql> CREATE VIEW v AS SELECT * FROM t1 COMMENt='mytable';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='mytable'' at line 1

Suggested fix:
Ideally, VIEWs would allow for COMMENTs at both column and table level. 
However, since columns are "taken" from the creation SELECT, it may be difficult to implement/choose how those columns are commented. 

I think we should at least allow COMMENTs at the table/view level for CREATE/ALTER VIEW.
[4 Aug 2011 11:30] Federico Razzoli
In information_schema.TABLES the value of TABLE_COMMENT column is "VIEW" for views. But this is completely useless, because the right way to identify VIEWs is to read the TABLE_TYPE column.
[6 Jul 2017 22:52] Bruno Aquino Filardi Filho
Please put this feature! Anyone working on this?
[20 Jul 2017 11:12] Paolo Puddu
Allowing comments to views would prevent me having to have maintain separate documentation for explaining some of the calculated fields I am producing in the view.
I would appreciate this feature being added.
Thanks
[2 Aug 2023 10:07] Sébastien F.
It would be appreciated :)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.