[SQL] Table Copy.
HI! I'm new to postgres. I need to have a table as a copy of another one. Example: CREATE TABLE one ( fileda INTEGER, filedb INTEGER, filedc INTEGER ); CREATE TABLE two ( fileda INTEGER, filedb INTEGER, filedc INTEGER ); As on insert to table one I should get the same insert on table two. As on delete to table one I should get the same delete on table two. As on update to table one I should get the same update on table two. Can someone provide the examples i can study ? Thanks in advance. Alex ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[SQL] DATE TIME INDEX ?
I have been tring to use index on timestamps: I have a table with a timestamp filed with index on it. I nned to extract all the ids of the table with datarx >= a date <= a date or between 2 dates I found that the only way to force postgres to use index is: explain select id,datarx::date from docs where datarx between '2002-11-13' and '2002-11-14' ; Index Scan using idx_documenti_datarx on documenti (cost=0.00..7.86 rows=2 width=12) In other cases the index is not used: explain select id,datarx::date from docs where datarx >= '2002-11-16'; Seq Scan on documenti (cost=0.00..12.01 rows=107 width=12) explain select id,datarx::date from docs where datarx::date between '2002-11-13' and '2002-11-13' ; Seq Scan on documenti (cost=0.00..16.02 rows=36 width=12) I found that the only way to force postgres to use index is: explain select id,datarx::date from docs where datarx between '2002-11-13' and '2002-11-14' ; Index Scan using idx_documenti_datarx on documenti (cost=0.00..7.86 rows=2 width=12) Do I need to use some other functons o trick? Thanks in advance Alex ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[SQL] INDEX PROBLEMS ?
On postgres 7.2.3 I have found what follows: explain select * from documents where iddoc>1; Seq Scan on lotti (cost=0.00..831.79 rows=26783 width=98) EXPLAIN explain select * from documents where iddoc=1; Index Scan using lotti_pkey on lotti (cost=0.00..2.26 rows=1 width=98) Why index is not used for operators > and < Alex ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html