SQL: Comments
Welcome to the Comments lesson!
This lesson is shown as static text below. However, it's designed to be used interactively. Click the button below to start!
In SQL, comments begin with
--. This is an unusual syntax for comments, although it is shared with some other programming languages, like Ada and Haskell. Anything from the--until the end of the line gets ignored.>
exec(`CREATE TABLE cats (name TEXT-- owner_name TEXT)`);exec(`INSERT INTO cats (name, owner_name) VALUES ('Wilford', 'Wilford')`);Result:
Error: table cats has no column named owner_name
SQL databases also support C-style comments
/* like this */, which can span multiple lines.>
exec(`CREATE TABLE cats (id INTEGER PRIMARY KEY/*name TEXT,owner_name TEXT*/)`);exec(`INSERT INTO cats (name, owner_name) VALUES ('Wilford', 'Wilford')`);Result:
Error: table cats has no column named name