“column not allowed here” error in INSERT statement

You’re missing quotes around the first value, it should be INSERT INTO LOCATION VALUES(‘PQ95VM’, ‘HAPPY_STREET’, ‘FRANCE’); Incidentally, you’d be well-advised to specify the column names explicitly in the INSERT, for reasons of readability, maintainability and robustness, i.e. INSERT INTO LOCATION (POSTCODE, STREET_NAME, CITY) VALUES (‘PQ95VM’, ‘HAPPY_STREET’, ‘FRANCE’);

How does COPY work and why is it so much faster than INSERT?

There are a number of factors at work here: Network latency and round-trip delays Per-statement overheads in PostgreSQL Context switches and scheduler delays COMMIT costs, if for people doing one commit per insert (you aren’t) COPY-specific optimisations for bulk loading Network latency If the server is remote, you might be “paying” a per-statement fixed time … Read more

Cannot INSERT: ERROR: array value must start with “{” or dimension information

Your column username seems to be an array type, so the literal ‘mahman’ is not valid input for it. It would have to be ‘{mahman}’: INSERT INTO user_data.user_data (username,randomint) VALUES (‘{mahman}’,1); (Or make it a plain varchar column or text column instead.) Update confirms it: character varying(50)[] is an array of character varying(50). About array … Read more

Is there any way to show progress on a `gunzip < database.sql.gz | mysql ...` process?

You may use -v : Verbose mode (show progress) in your command, or there’s another method using Pipe Viewer (pv) which shows the progress of the gzip, gunzip command as follows: $ pv database1.sql.gz | gunzip | mysql -u root -p database1 This will output progress similar to scp: $ pv database1.sql.gz | gunzip | … Read more

SQL Insert into table only if record doesn’t exist [duplicate]

This might be a simple solution to achieve this: INSERT INTO funds (ID, date, price) SELECT 23, DATE(‘2013-02-12’), 22.5 FROM dual WHERE NOT EXISTS (SELECT 1 FROM funds WHERE ID = 23 AND date = DATE(‘2013-02-12’)); p.s. alternatively (if ID a primary key): INSERT INTO funds (ID, date, price) VALUES (23, DATE(‘2013-02-12’), 22.5) ON DUPLICATE … Read more