postgresql-8.4

How to get the total number of tables in postgresql?

ぃ、小莉子 提交于 2019-12-03 22:04:47
Is there any way by which I can get the total number of tables in a Postgresql database? The postgresql version I'm using is PostgreSQL 8.4.14. select count(*) from information_schema.tables; Or if you want to find the number of tables only for a specific schema: select count(*) from information_schema.tables where table_schema = 'public'; Just try to search in pg_stat... tables or information_schema you can find there very useful informations about your database. Example: select * from pg_stat_user_tables ; select count(*) from pg_stat_user_tables ; select * from pg_stat_all_tables ; pipaliya

Error “invalid byte sequence” while restoring PostgreSQL database

泄露秘密 提交于 2019-12-03 20:29:24
Earlier today, I was trying to restore my PostgreSQL (8.1.22) database from production using pgAdmin III. However, after the restoration procedure finished, it started throwing errors like: WARNING: errors ignored on restore: 4 Also, upon investigation I found that out of all the tables 3 tables hadn't been restored (contained 0 rows). When I checked the log, I found the follwoing error near the 3 tables: pg_restore: [archiver (db)] Error from TOC entry 5390; 0 442375 TABLE DATA tablename postgres pg_restore: [archiver (db)] COPY failed: ERROR: invalid byte sequence for encoding "UTF8":

PostgreSQL: between with datetime

纵然是瞬间 提交于 2019-12-03 11:55:49
问题 I use PostgreSQL 8.4.11 and find strange error. When I query: SELECT "documents_document"."given_on" FROM "documents_document" WHERE (EXTRACT('month' FROM "documents_document"."given_on") = 1 AND "documents_document"."given_on" BETWEEN '1-01-01 00:00:00' and '1-12-31 23:59:59.999999') ORDER BY "documents_document"."created_on" DESC I get results: given_on ------------ 2002-01-16 2011-01-25 2012-01-12 2012-01-12 2012-01-12 2012-01-20 2012-01-19 2012-01-13 2012-01-31 2012-01-16 2012-01-31 2012

postgresql - can't create database - OperationalError: source database “template1” is being accessed by other users

大憨熊 提交于 2019-12-03 08:58:39
问题 I logged in to source database template1 and now I can't create database. When I try to create database, I get this error: OperationalError: source database "template1" is being accessed by other users DETAIL: There are 5 other session(s) using the database. Every time I login to template1, I use 'exit' command to logout, but as you can see it does not logout and number of sessions increases everytime I login. Is there a way to force disconnect every connection to template1 that logged in now

Cannot get log_min_duration_statement to work

让人想犯罪 __ 提交于 2019-12-03 07:58:08
I have been googling for more than 2 hours, but I am really stuck with this one. I want PostgreSQL (I am using version 8.4 on Debian) to start logging slow queries only. To that extend I use the following configuration in postgresql.conf : log_destination = 'csvlog' logging_collector = on log_min_messages = log log_min_duration_statement = 1000 log_duration = on log_line_prefix = '%t ' log_statement = 'all' The rest of the configuration is all on default settings (commented out). The logging works, but it logs all statements, even the ones below the threshold of 1000 (ms). If I do a 'show all'

Options to retrieve the current (on a moment of running query) sequence value

混江龙づ霸主 提交于 2019-12-03 06:29:05
问题 How is it possible to get the current sequence value in postgresql 8.4? Note: I need the value for the some sort of statistics, just retrieve and store. Nothing related to the concurrency and race conditions in case of manually incrementing it isn't relevant to the question. Note 2: The sequence is shared across several tables Note 3: currval won't work because of: Return the value most recently obtained by nextval for this sequence in the current session ERROR: currval of sequence "<sequence

Using psql to connect to postgresql in ssl mode

杀马特。学长 韩版系。学妹 提交于 2019-12-03 03:25:43
问题 I am trying to configure ssl certificate for postgreSQL server. I have created a certificate file (server.crt) and key (server.key) in data directory and update the parameter SSL to "on" to enable secure connection. I just want only the server to be authenticated with server certificates on the client side and dont require the authenticity of client at server side. I am using psql as a client to connect and execute the commands. I am using PostgreSQL 8.4 and linux. I tried with the below

PostgreSQL: between with datetime

≡放荡痞女 提交于 2019-12-03 02:15:15
I use PostgreSQL 8.4.11 and find strange error. When I query: SELECT "documents_document"."given_on" FROM "documents_document" WHERE (EXTRACT('month' FROM "documents_document"."given_on") = 1 AND "documents_document"."given_on" BETWEEN '1-01-01 00:00:00' and '1-12-31 23:59:59.999999') ORDER BY "documents_document"."created_on" DESC I get results: given_on ------------ 2002-01-16 2011-01-25 2012-01-12 2012-01-12 2012-01-12 2012-01-20 2012-01-19 2012-01-13 2012-01-31 2012-01-16 2012-01-31 2012-01-12 ... Why? I would expect dates in interval 1-01-01 ... 1-12-31. You expected 1-01-01 ... 1-12-31 .

currval has not yet been defined this session, how to get multi-session sequences?

本小妞迷上赌 提交于 2019-12-03 01:12:15
My objective is to get a primary key field automatically inserted when inserting new row in the table. How to get a sequence going from session to session in PostgreSQL? doubleemploi@hanbei:/home/yves$ psql -d test Mot de passe : psql (8.4.13) Saisissez « help » pour l''aide. test=> create sequence test001 start 10; CREATE SEQUENCE test=> select currval('test001'); ERREUR: la valeur courante (currval) de la séquence « test00 » n''est pas encore définie dans cette session --- current value not yet defined this session (???) test=> select setval('test001', 10); setval -------- 10 (1 ligne) test=

postgresql - can't create database - OperationalError: source database “template1” is being accessed by other users

左心房为你撑大大i 提交于 2019-12-02 21:43:36
I logged in to source database template1 and now I can't create database. When I try to create database, I get this error: OperationalError: source database "template1" is being accessed by other users DETAIL: There are 5 other session(s) using the database. Every time I login to template1, I use 'exit' command to logout, but as you can see it does not logout and number of sessions increases everytime I login. Is there a way to force disconnect every connection to template1 that logged in now? Database template1 exists only to provide barebone structure to create another empty database. You