Skip site navigation (1) Skip section navigation (2)

Re: Two novice questions

From: Shane Ambler <pgsql(at)Sheeky(dot)Biz>
To: stafford(at)marine(dot)rutgers(dot)edu
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Two novice questions
Date: 2008-07-14 16:04:30
Message-ID: 487B790E.3030300@Sheeky.Biz (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Wm.A.Stafford wrote:
> I have received a collection of scripts to be used to build a PostgreSQL 
> db and I can't figure out the following.
> 1.  Usage of quotes in the scripts.
> The following comes from a script to build and populate a table:
> gid serial PRIMARY KEY,
> "fid_" int4,
> Why is the second column name in quotes, i.e. what is the difference 
> between fid_ int4 and "fid_" int 4.

The use of quotes preserves the case and also allows identifier names to 
be keywords and to also contain spaces. What triggers identifiers to be 
quoted will depend on the program used to create the script. My guess 
here is that it only searches for lowercase alpha and numeric contents 
in identifiers and quotes otherwise, meaning the underscore may have 
triggered the quoting.

> In a similar vein, this comes from a  script that creates a couple of 
> tables:
> create table schema1."cache" ( ...
> create table schema1.cache2 ( ...
> Here one schema name is quoted and the other is not.

As above - cache is listed as a non-reserved keyword. cache2 is not.

> 2.  How does one run a script from PGAdmin?  I have been 'opening' the 
> script file then hitting the run button.  Is there a way to just specify 
> the path to the script?

I don't believe there is in pgadmin. If you use psql (the cli client for 
postgresql) then you can run the script with \i or as an option when 
starting psql.


Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

In response to

pgsql-novice by date

Next:From: Ridvan Lakas ng Bayan S. BaluyosDate: 2008-07-17 04:49:17
Subject: Stopping a transaction as soon as an error occurs
Previous:From: Tom LaneDate: 2008-07-14 15:55:23
Subject: Re: Two novice questions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group