User can not create a new table

Started by Tulio Oliveiraover 25 years ago5 messagesgeneral
Jump to latest
#1webb sprague
wsprague@o1.com
In reply to: Tulio Oliveira (#2)
Fixed width COPY

Does anybody know of a good way to COPY a file into a table if the data is
based on fixed width format? Do I just have to write some code with
scanf(Ick)? For example (Sorry about the poor ASCII art formatting):

| FIELD DESCRIPTION LENGTH POSITION|
|_______________________________________________________|
| 1. Action (E=eff, D=del, P=pend eff) 1 1
| 2. Action Date (mmddyy) 6 2-7
| 3. Country Code 3 8-10
| 4. filler 1 11
5. Paired Code 3 12-14
| 6. filler 1 15
| 7. Country Name 65 16-80
| 8. Footnote code (LERGINFO, Sec 1.1) 1 81
| 9. filler 9 82-90

#2Tulio Oliveira
mestredosmagos@marilia.com

Hello, All

How I prevent a new user to create new tables in a Data Base ?

The Data Base is owned by "postgres" and I need that only the "postgres"
user can create new tables ...

-------

Where are the default messages thats appears when the Referentian
Integrity is violated ? I need change this message to portuguese...

regards,

tulio oliveira

--
Um velho homem s�bio disse uma vez: "Quando voc� atualiza um exploit,
voc� �
bom. Quando voc� � o primeiro a hackear cada sucessiva vers�o de um
produto
que roda em milh�es de computadores pela Internet, voc� cria uma
Dinastia".

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Tulio Oliveira (#2)
Re: User can not create a new table

On Mon, 7 May 2001, Tulio Oliveira wrote:

Hello, All

How I prevent a new user to create new tables in a Data Base ?

The Data Base is owned by "postgres" and I need that only the "postgres"
user can create new tables ...

I don't think you can allow users to connect to a db but not create
tables at this time. You should be able to disallow connects to the
db, but I'm guessing that's not what you want.

Where are the default messages thats appears when the Referentian
Integrity is violated ? I need change this message to portuguese...

It's compiled in I think from backend/utils/adt/ri_triggers.c

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: webb sprague (#1)
Re: Fixed width COPY

webb sprague <wsprague@o1.com> writes:

Does anybody know of a good way to COPY a file into a table if the data is
based on fixed width format?

COPY insists on having delimiters; you'll need to translate the file
format into something COPY can deal with.

Do I just have to write some code with scanf(Ick)?

If you like C, that would work, but you could doubtless accomplish the
same result with very short scripts in sed, awk, perl, tcl, or half a
dozen other text-bashing tools. Pick your poison...

regards, tom lane

#5Jeff Eckermann
jeckermann@verio.net
In reply to: Tom Lane (#4)
RE: Fixed width COPY

COPY is unfortunately not flexible. You will need to edit the data to
insert delimiters (check first to make sure that your choice of delimiter
does not appear in your data).
You had best delete all of the leading and trailing whitespace in each field
as well, to avoid trouble with non text-type datatypes.
For an easy script, you could check out GNU Awk (gawk), which lets you split
fields based on widths: your script might look something like:

BEGIN {
FIELDWIDTHS = "width1 width2 width3.... widthn" # set field widths for
splitting
OFS = "\t" # set output field separator

}
{
$1 = $1 # Force field splitting based on
widths
for (i = 1; i <= NF; i++) { # Loop through fields,
deleting leading & trailing spaces
sub (/^ +/, "", $i)
sub (/ +$/, "", $i)
}
print # Output the result
}

"width1" etc is just width in characters for each field.
This example uses tabs as delimiter, but you can specify whatever you want.
I'm sure that Perl can easily do this too, but I don't know enough to
suggest a script.
Forgive me if you know all of this already. I get carried away sometimes.

Show quoted text

-----Original Message-----
From: webb sprague [SMTP:wsprague@o1.com]
Sent: Monday, May 07, 2001 2:45 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Fixed width COPY

Does anybody know of a good way to COPY a file into a table if the data is

based on fixed width format? Do I just have to write some code with
scanf(Ick)? For example (Sorry about the poor ASCII art formatting):

| FIELD DESCRIPTION LENGTH POSITION|
|_______________________________________________________|
| 1. Action (E=eff, D=del, P=pend eff) 1 1
| 2. Action Date (mmddyy) 6 2-7
| 3. Country Code 3
8-10
| 4. filler 1 11
5. Paired Code 3 12-14
| 6. filler 1
15
| 7. Country Name 65 16-80
| 8. Footnote code (LERGINFO, Sec 1.1) 1 81
| 9. filler 9
82-90

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html