The following example copies a table to standard output, using a vertical bar \(\"|\"\) as the field delimiter:
The following example copies a table to standard output, using a vertical bar \(\"|\"\) as the field delimiter:
COPY country TO stdout WITH DELIMITER '|';
COPY country TO stdout USING DELIMITERS '|';
To copy data from a Unix file into a table \"country\":
To copy data from a Unix file into a table \"country\":
COPY country FROM '/usr1/proj/bray/sql/country_data';
COPY country FROM '/usr1/proj/bray/sql/country_data';
...
@@ -93,12 +93,13 @@ The format for each instance in the file is as follows. Note that this format mu
...
@@ -93,12 +93,13 @@ The format for each instance in the file is as follows. Note that this format mu
The " {} "BINARY" {bold} " keyword will force all data to be stored/read as binary objects rather than as text. It is somewhat faster than the normal copy command, but is not generally portable, and the files \
The " {} "BINARY" {bold} " keyword will force all data to be stored/read as binary objects rather than as text. It is somewhat faster than the normal copy command, but is not generally portable, and the files \
generated are somewhat larger, although this factor is highly dependent on the data itself. By default, a text copy uses a tab \
generated are somewhat larger, although this factor is highly dependent on the data itself. By default, a text copy uses a tab \
\(\"\\t\"\) character as a delimiter. The delimiter may also be changed to any other single character with the keyword phrase WITH DELIMITER. Characters in data fields which happen to match the delimiter character will be quoted.
\(\"\\t\"\) character as a delimiter. The delimiter may also be changed to any other single character with the keyword phrase USING DELIMITERS. Characters in data fields which happen to match the delimiter character will be quoted.
You must have select access on any table whose values are read by " {} "COPY" {bold} ", and either insert or update access to a table into which values are being inserted by \
You must have select access on any table whose values are read by " {} "COPY" {bold} ", and either insert or update access to a table into which values are being inserted by \
" {} "COPY" {bold} ". The backend also needs appropriate Unix permissions for any file read or written by \
" {} "COPY" {bold} ". The backend also needs appropriate Unix permissions for any file read or written by \
" {} "COPY" {bold} ".
" {} "COPY" {bold} ".
The keyword phrase " {} "WITH DELIMITER" {bold} " specifies a single character to be used for all delimiters between columns.
The keyword phrase " {} "USING DELIMITERS" {bold} " specifies a single character to be used for all delimiters between columns. If multiple characters are specified in the delimiter string, only the first \
character is used.
Tip: Do not confuse " {} "COPY" {bold} " with the psql instruction \\copy. "
Tip: Do not confuse " {} "COPY" {bold} " with the psql instruction \\copy. "
if [catch {wpg_select $CurrentDB "select datlastsysoid from pg_database where datname='$dbname'" rec {
wpg_select $CurrentDB "select oid from pg_database where datname='template1'" rec {
set maxim $rec(datlastsysoid)
set maxim $rec(oid)
}
}]{
catch {
wpg_select $CurrentDB "select oid from pg_database where datname='template1'" rec {
set maxim $rec(oid)
}
}
}
}
}
.pgaw:Main.lb delete 0 end
.pgaw:Main.lb delete 0 end
...
@@ -301,17 +295,19 @@ catch {
...
@@ -301,17 +295,19 @@ catch {
}
}
proc {cmd_Views}{}{
proc {cmd_Views}{}{
global CurrentDB PgAcVar
global CurrentDB
setCursor CLOCK
setCursor CLOCK
.pgaw:Main.lb delete 0 end
.pgaw:Main.lb delete 0 end
catch {
catch {
if {! $PgAcVar(pref,systemtables)}{
wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (relname !~ '^pg_') and (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec{
set sysconstraint "where (viewname !~ '^pg_') and (viewname !~ '^pga_')"
if {$rec(count)!=0}{
} else {
set itsaview($rec(relname)) 1
set sysconstraint ""
}
}
}
wpg_select $CurrentDB "select viewname from pg_views $sysconstraint order by viewname" rec {
wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') and (relhasrules) order by relname" rec {
showError [format [intlmsg "Schema '%s' was not found!"] $PgAcVar(schema,name)]
pg_result $pgres -clear
return
}
set tuple [pg_result $pgres -getTuple 0]
set links [lindex $tuple 1]
pg_result $pgres -clear
set linkslist {}
set PgAcVar(schema,links)$links
foreach link $PgAcVar(schema,links){
set linklist {}
foreach {tbl fld} $link {
if {$tbl==$tbl_name}{
if {$fld==$old_name}{ set fld $new_name}
}
lappend linklist $tbl $fld
}
lappend linkslist $linklist
}
sql_exec noquiet "update pga_schema set schemalinks='$linkslist' where schemaname='$schema'"
}
proc {tbl_rename}{{old_name}{new_name}}{
global PgAcVar CurrentDB
catch {
wpg_select $CurrentDB "select schemaname from pga_schema where (schematables like '$old_name %') or (schematables like '% $old_name %') order by schemaname" rec {
set pgres [wpg_exec $CurrentDB "insert into pga_schema values ('$PgAcVar(schema,name)','$tables','$PgAcVar(schema,links)')"]
set pgres [wpg_exec $CurrentDB "insert into pga_schema values ('$PgAcVar(schema,name)','$tables','$PgAcVar(schema,links)')"]
} else {
} else {
set pgres [wpg_exec $CurrentDB "update pga_schema set schemaname='$PgAcVar(schema,name)',schematables='$tables',schemalinks='$PgAcVar(schema,links)' where oid=$PgAcVar(schema,oid)"]
set pgres [wpg_exec $CurrentDB "update pga_schema set schemaname='$PgAcVar(schema,name)',schematables='$tables',schemalinks='$PgAcVar(schema,links)' where oid=$PgAcVar(schema,oid)"]
# showError [intlmsg "$tables"]
}
}
setCursor DEFAULT
setCursor DEFAULT
if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} then {
if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} then {
wpg_select $CurrentDB "select indexrelid from pg_index, pg_class where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_index.indrelid)" rec {
wpg_select $CurrentDB "select oid,indexrelid from pg_index where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_index.indrelid)" rec {