Je veux append un commentaire en code SQL. Comment puis-je faire ceci? J’utilise MySQL.
Plusieurs façons:
# Comment -- Comment /* Comment */
Voir les documents .
“Un commentaire pour une colonne peut être spécifié avec l’option COMMENT
. Le commentaire est affiché par les instructions SHOW CREATE TABLE
et SHOW FULL COLUMNS
. Cette option est opérationnelle à partir de MySQL 4.1. (Elle est autorisée mais ignorée dans les versions antérieures.)”
Par exemple
-- -- Table structure for table 'accesslog' -- CREATE TABLE accesslog ( aid int(10) NOT NULL auto_increment COMMENT 'unique ID for each access entry', title varchar(255) default NULL COMMENT 'the title of the page being accessed', path varchar(255) default NULL COMMENT 'the local path of teh page being accessed', .... ) TYPE=MyISAM;
Vous pouvez utiliser des commentaires sur une seule ligne:
-- this is a comment # this is also a comment
Ou un commentaire multiligne:
/* multiline comment */
De là, vous pouvez utiliser
# For single line comments -- Also for single line, must be followed by space/control character /* C-style multiline comment */
Trois types de commentaires sont pris en charge
Ligne simple de hachage commentant en utilisant #
Select * from users ; # this will list users
Select * from users ; -- this will list users
Note: il est important d’avoir un espace blanc juste après –
3) Commentaire multi-lignes en utilisant / * * /
Select * from users ; /* this will list users */
/* comment here */
voici un exemple: SELECT 1 /* this is an in-line comment */ + 1;