Well, I reckon we've all once rebooted the wrong server, locked ourselves out of a live server with a wrong iptables rule etc.
But since I do databases full time, I kind of got *far* more careful. And I'm *so* glad that there are transactions 😇
s/production/developmestruction/
You essentially have four options now:
* restore to a new DB and write a client that syncs them
* try to restore in a single transaction (i.e., use --single-transaction
and --clean
in pg_restore
) and hope that your clients can cope with it (and that you have a proper pg_dump
, not just an SQL file...).
* if you only have a text/SQL file, sed
, grep
, vi
and friends can help you restore the tables you f***ed up as new tables and then you might be able to re-fill your live tables with what you destroyed...
* schedule a downtime and do a proper restore
At the end of the day, anything that has been chanced in the DB since you dumped will be lost, unless you manage to get option #1 or #3 working, so...
Oh, and: Once you have this situation sorted, you should set up a "playground" copy of your DB that you can actually play around with. And familiarize yourself with things like PITR, RTO/RPO/RCO, real backups etc. pp.
Yeah, PostgreSQL made me learn NULL casting...
NULL::integer
NULL::text
Because Nulls are not typed, and without those, I had so many complaints. (I cannot find the function you are calling, despite you typing the name perfectly... With the parameters passed)...
Ughh, after awhile, you get used to it.
Yh i made a back up earlier
And now restoring it
And I am not sure if I can do: create empty db and restore to that
Why because it is a production thing
Hello,
I'm getting this error while connecting from test to prod. i made all necessary entries in hba file. But application did not face this issue. Any one have idea on this?
psql: error: connection to server on
"10.200.00.01", port 5432 failed: FATAL: no pg_hba.conf entry for host "10.34.00.01", user "dba", database "postgres", no encryption
It would be easier if you share a test case, I mean, show us the creation of the table and your insert and select from that table.
Читать полностью…I didn’t get what’s the issue: Postgres is wrongly converting your empty string in NULL value so it doesn’t allow u to add the entry in the table?
Читать полностью…I have a New Client... ncdb
And I SOLELY operate in nctest
When I connect with psql, the prompts get different colors.
https://momjian.us/main/writings/pgsql/nulls.pdf
helped me a lot to wrap my head around it ;-)
Hello Guys,
can I know which method I can use in this case.
I've timescaledb and a hypertable in my source. I just needed to replicate and copy all the data in this hypertable to a new exactly same structure table in the same server or the same database, and also any ongoing changes will be replicated as well.
Thanks in advance
That sounds like you're trying to restore, not back up... Try renaming your broken DB and restore to an empty new one.
Читать полностью…Absolutely stuck with a restoration:
So I backed up my db
And made lots of changes
But missed one dependency case
Now I have to restore the backup and redo all of the changes within hrs
But not able to back it up
There are so many errors ( must be a member, table exists, column exists etc )
-ps backend developers given with DE work, working on pgadmin
Just startedup with data handling so any help is good help
Did you (hopefully) put a hostssl
entry into pg_hba.conf? Or is there another line without the "no encryption" above it as well?
can you plz tell how to deal with '' constraint if someone will pass '' this then I dot want to allow him/her?
Читать полностью…CREATE TABLE Orders (
order_id SERIAL PRIMARY KEY, -- Auto-incrementing primary key
order_date TIMESTAMP DEFAULT NOW(), -- Date and time of the order
total_amount NUMERIC(10, 2) NOT NULL, -- Total amount for the order
txt TEXT NOT NULL -- Text field, cannot be NULL
); I created table like this now I am trying to add record
INSERT INTO Orders ( total_amount, txt) VALUES (250.75, '' ); even though I pass null value still allowing; however txt field has not null constraint
I'm pretty sure OP has an Oracle background...
An empty string (''
) is not NULL
, even if Oracle treats it that way. No other proper DBMS or the SQL standard does so, btw.