Comments in .sql files

From: "Chad N(dot) Tindel" <chad(at)tindel(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Comments in .sql files
Date: 2003-07-24 04:36:06
Message-ID: 20030724043606.GA31855@calma.pair.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Still working on converting our schemas over to postgres from mysql, and trying
to get the hang of the differences between the two products.

I'm trying to figure out how to put comments in our .sql schema files.
For example:

a.sql
-----------------------
drop table A;
create table A (
id SERIAL PRIMARY KEY,
foo int default 5,
bar int default 10
);

# This is a comment
insert into A (foo, bar) values (1, 1);
insert into A (foo, bar) values (2, 2);
-------------------------

Running "psql --username=user -d DB < a.sql" yields the following result:

DROP TABLE
NOTICE: CREATE TABLE will create implicit sequence 'a_id_seq' for SERIAL column 'a.id'
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'a_pkey' for table 'a'
CREATE TABLE
ERROR: parser: parse error at or near "#" at character 1
INSERT 66820 1

------------------

And the DB only shows the second entry:

Portal=# select * from A;
id | foo | bar
----+-----+-----
1 | 2 | 2
(1 row)

----------------

So, my questions are:

1. It obviously doesn't like the # notation for comments. What is the proper
way to put comments in schema files?

2. Why does postgres ignore the first insert? Shouldn't it just barf on
the "#" line and keep going?

3. Is there a way to turn of the notices about creating implicit sequences
and indices?

Thanks,

Chad

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Madhavi Daroor 2003-07-24 04:46:55 Parse Error neaer NullOrder
Previous Message Greg Stark 2003-07-24 04:15:02 Re: 0/1 vs true/false