[SQL] Foreign key
Hello, When i add table with foreign key in my database, this error return : « number of referencing and referenced colums for foreign key disagree». How resolve this problem ? Thanks alain SAKALALA Mailto:[EMAIL PROTECTED]
[SQL] Auto Numbering
hello sir/madam, How to enable autonumbering in pgsql. How Can i implement autonumbering. Am using servlets,jsp and tomcat to develope web applications. regards sreekanth__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
[SQL] Is there a way to find a schema name
Would like to know if there is a way to find a schema name (when in the schema through a application or through psql). Thanks KC ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[SQL] select a list of schema names
I want to implement a multi-company database where each schema represents different company. I created a number of schemas in a database. How to select a list of schema names which current user is authorized to access ? I want to get the list of companies to allow user pick the one. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
Re: [SQL] timestamp precision - can I control precision at select time
thanks, christoph. i did go ahead and retool all the tables, but glad to know about the casting option. ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
[SQL] How to make update statement to work
I want to nullify fields which does not exist in reference table.
I tried
UPDATE demo.toode
SET "liik"=NULL,"grupp"=NULL
WHERE ("grupp","liik") NOT IN
(SELECT ("grupp", "liik") FROM "artliik")
but this causes error:
ERROR: operator does not exist: character = record
HINT: No operator matches the given name and argument type(s). You may need
to add explicit type casts.
How to write this UPDATE statement properly ?
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
[SQL] Permissions on tables
Hi, I have a requirement where I have a table and a view on top of it. I want to make some changes so that a user in a given group would be able to insert/update only on the view (ofcourse i have a rule which inserts/updates the table) but not on the underlying table. I tried revoke the insert/update permissions on the table, but it fails even the inserts/updates on the view. How can i set these permissions ? Thanks, Subhash. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[SQL] Accessing other Databases
Hi all. Anybody knows some way to access other database inside of a different database(under the same instalation of postgres)? Like the example under: I have two database under the same instalation(database A and B). I am doing some queries in A - pslq A - and inside A, I want to access, tables, functions in B, is't possible? ( I know how to do this in Sybase) Thanks Osmar ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
[SQL] Merging item codes using referential integrity
I have item table and a lot of child tables where the items are used.
I want to merge two item codes into single item in all tables.
It is not nice to write a lot of separate UPDATE statements for each table.
So I want to utilize REFERENCES clause for merging.
I tried the following code but got duplicate key error in UPDATE
statement.
Any idea how to impement this?
CREATE TABLE parent ( code CHAR(10) PRIMARY KEY );
CREATE TABLE orders ( anyfield CHAR(10) REFERENCES parent ON UPDATE
CASCADE );
CREATE TABLE invoices ( anyotherfield CHAR(10) REFERENCES parent ON UPDATE
CASCADE );
-- ... a lot of more child tables with different table and field names
but -- always with same REFERENCES clause.
INSERT INTO parent VALUES ('1');
INSERT INTO parent VALUES ('2');
INSERT INTO orders VALUES ('1');
INSERT INTO invoices VALUES ('1');
INSERT INTO orders VALUES ('2');
INSERT INTO invoices VALUES ('2');
BEGIN;
-- Direct Postgres to update all child tables. This causes error.
UPDATE parent SET code='1' WHERE code='2';
-- Remove duplicate row
CREATE TABLE parent AS
SELECT * FROM parent
GROUP BY CODE ;
COMMIT;
Andrus.
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: [SQL] Auto Numbering
On Tue, Mar 22, 2005 at 11:25:10AM -0800, sreekanth pk wrote: > > How to enable autonumbering in pgsql. See "How do I create a serial/auto-incrementing field?" in the FAQ: http://www.postgresql.org/docs/faqs.FAQ.html#4.11.1 If that's not what you're looking for then please be more specific. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---(end of broadcast)--- TIP 8: explain analyze is your friend
Re: [SQL] Foreign key
On Fri, Mar 25, 2005 at 04:31:16PM +0100, [EMAIL PROTECTED] wrote: > > When i add table with foreign key in my database, this error return : < > number of referencing and referenced colums for foreign key disagree>. Apparently the referencing key (the foreign key specification) has a different number of columns than the referenced key (the primary key or other unique key in the referenced table). Here's an example that illustrates the problem: CREATE TABLE foo ( pk1 integer NOT NULL, pk2 integer NOT NULL, PRIMARY KEY (pk1, pk2) -- 2-column primary key ); CREATE TABLE bar ( fk integer NOT NULL REFERENCES foo -- 1-column foreign key ); ERROR: number of referencing and referenced columns for foreign key disagree In the above example we need a 2-column foreign key: CREATE TABLE bar ( fk1 integer NOT NULL, fk2 integer NOT NULL, FOREIGN KEY (fk1, fk2) REFERENCES foo ); Here's another example that references a 1-column unique key that isn't a primary key: CREATE TABLE foo ( pk1 integer NOT NULL, pk2 integer NOT NULL, xinteger NOT NULL, PRIMARY KEY (pk1, pk2), UNIQUE (x) ); CREATE TABLE bar ( fk integer NOT NULL REFERENCES foo (x) ); If these examples don't help, then please post the table definitions you're working with and explain what you'd like to do. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
