SybaseIQ: Drop Table with special character - tsql

I'm trying to delete a table named DBA.[ in Sybase IQ database. This is a wrong table which is not desired so we need to delete it. I've tried several options but not successful. Please share any workaround to drop the table, if anyone knows.
iqisql -Udba -P*** -Sdwhdb -w500
1> drop table dba.[
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '
' on line 2
1> drop table dba.[[]
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '[[' on line 1
1> drop table 'dba.[ '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near 'dba.[ ' on line 1
1> drop table dba.[
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '\' on line 1
1> drop table 'dba.[ '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near 'dba.[ ' on line 1
1> drop table 'dba.[[ '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near 'dba.[[ ' on line 1
1> drop table 'dba.['
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near 'dba.[' on line 1
1> drop table 'dba.[['
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near 'dba.[[' on line 1
1> drop table dba.[
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '\' on line 1
1> drop table dba.'[ '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '[ ' on line 1
1> drop table dba.'[[ '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '[[ ' on line 1
1> drop table dba.'[[] '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '[[] ' on line 1
1> drop table dba.'[[] '
2> go
Msg 102, Level 15, State 0:
SQL Anywhere Error -131: Syntax error near '[[] ' on line 1

Related

Why does one of these very similar jsonpaths work, but not the other?

Bumped into this while debugging a query from the ORM and have no idea why it happens. Asking mostly out of curiosity. In PostgreSQL 12.5 the following occurs:
-- All good:
select ('$[*] ? (#.live_at <= 2020-11-18)')::jsonpath
jsonpath |
---------------------------------------|
$[*]?(#."live_at" <= (2020 - 11) - 18) |
-- But then:
select ('$[*] ? (#.live_at <= 2020-05-18)')::jsonpath
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
SQL Error [42601]: ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
ERROR: syntax error, unexpected IDENT_P at end of jsonpath input
Position: 9
I've a suspicion that this is related to octal representation, but node seems to eat 2020-05-18 just fine. What gives?

Unable To Assign Query Result To A Variable In PostgreSQL

I have been struggling to assign the query result to a temp variable in PostgreSQL and I just can't get it to work. Can anyone guide please?
I tried with the both the below queries and I get the error shown below. I then tried with temp table. But it still fails during the assignment to the temp variable.
set var.ITEM_ID =(select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999');
set var.ITEM_ID = select t.item_id from api_item t inner join api_identifier i on i.item_id=t.item_id where i.value='99999';
The first statement throws the error :-
[2020-03-03 08:10:50] [42601] ERROR: syntax error at or near "("
[2020-03-03 08:10:50] Position: 23
Second one throws the below error:-
[2020-03-03 08:10:55] [42601] ERROR: syntax error at or near "select"
[2020-03-03 08:10:55] Position: 24

syntax error at or near "'select to_char(application_date::timestamp, '"

EXECUTE 'select to_char(application_date::timestamp, 'Mon-YY') as appl_month from my_schema.my_table;';
The above PostgreSQL EXECUTE statement is giving the below error:
ERROR: syntax error at or near "'select
to_char(application_date::timestamp, '" LINE 1: EXECUTE 'select
to_char(application_date::timestamp, 'Mon-YY...
^
********** Error **********
ERROR: syntax error at or near "'select
to_char(application_date::timestamp, '" SQL state: 42601 Character: 9
Any suggestions will be helpful.
Changed to below statement
EXECUTE 'select to_char(application_date::timestamp, ' || quote_literal(Mon-YY) || ') from standard.npo_weekly_export;';
But giving new error:
ERROR: syntax error at or near "'select to_char(application_date::timestamp, '"
LINE 1: EXECUTE 'select to_char(application_date::timestamp, ' || qu...
^
********** Error **********
ERROR: syntax error at or near "'select to_char(application_date::timestamp, '"
SQL state: 42601
Character: 9
Expected Output: - Counts by month in Mon-YY format
Application month Application # Final Approval #
Jan-17 1,000 800
Feb-17 1,010 808
Mar-17 1,020 816
Apr-17 1,030 824
If I do the below query:
select to_char(application_date, 'Mon-YY') as appl_month,
count(distinct application_id) as appl_count,
sum(final_approval_ind) as fa_count,
from my_schema.my_table
group by appl_month
order by appl_month;
Generated output: (Note: Sorted by text, not by date)
"Apr-17";94374;19953
"Apr-18";87446;20903
"Aug-17";102043;21536
"Aug-18";91107;20386
"Dec-17";63263;13755
"Dec-18";21358;74
"Feb-17";89447;18084
"Feb-18";75426;16144
"Jan-17";86103;16394
"Jan-18";79403;17766
"Jul-17";90380;18929
"Jul-18";85439;20186
"Jun-17";95596;20403
"Jun-18";85764;18707
"Mar-17";112929;23323
"Mar-18";91179;21841
"May-17";101907;22349
"May-18";90885;21550
"Nov-17";78284;16791
"Nov-18";80472;7656
"Oct-17";87955;18524
"Oct-18";82821;17056
"Sep-17";80740;17788
"Sep-18";75785;18009
Problem: to_char() returns text and it sorts by text and not by date. So the output is jumbled rather than sorted by Mon-YY.
Do the aggregation in a derived table (aka "sub-query") that preserves the data type, then do the sorting in the outer query:
select to_char(ap_month, 'Mon-YY') as appl_month
appl_count,
fa_count
from (
select date_trunc('month', application_date) as ap_month,
count(distinct application_id) as appl_count,
sum(final_approval_ind) as fa_count,
from my_schema.my_table
group by ap_month
) t
order by ap_month;
date_trunc('month', application_date) will normalize the application_date to the start of the month, but will retain the date data type, so that the sorting in the outer query works correctly.
I have no idea what the dynamic SQL in your question is supposed to do, but if you need to use that query for whatever reasons as dynamic SQL, you need to escape the single quotes by doubling them.
execute '
select to_char(ap_month, ''Mon-YY'') as appl_month
appl_count,
fa_count
from (
select date_trunc(''month'', application_date) as ap_month,
count(distinct application_id) as appl_count,
sum(final_approval_ind) as fa_count,
from my_schema.my_table
group by ap_month
) t
order by ap_month;
'; -- end of dynamic SQL
But using Postgres' dollar quoting would be easier:
execute $dyn$
select to_char(ap_month, 'Mon-YY') as appl_month
appl_count,
fa_count
from (
select date_trunc('month', application_date) as ap_month,
count(distinct application_id) as appl_count,
sum(final_approval_ind) as fa_count,
from my_schema.my_table
group by ap_month
) t
order by ap_month;
$dyn$; -- end of dynamic SQL
Note that you can nest dollar quoted strings, so if that query is used inside a function, just use a different delimiter than you use for the function body (see the example in the manual)

Why 'multi-part identifier' and why can't it be bound?

I continually receive these errors when I try to do a select with linked server on other tables. I end up rewriting the query, changing the order of joins, modifying some groups and then it works at the end, but I can not understand it.
SELECT TOP (100) PERCENT [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_COGNOME + ' ' + [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_NOME AS UTENTE, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.TELEFONI.S_TEL AS TEL,
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.SEDI.S_DESCR AS PIANO, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_QT AS NETNAME, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.EMAIL.S_EMAIL AS EMAIL,
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_DOMINIO AS DOMINIO, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.UFFICI.S_DESCR AS SERVIZIO, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.AZIENDE.S_DESCR AS AZIENDA
FROM [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.AZIENDE RIGHT OUTER JOIN
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.EMAIL RIGHT OUTER JOIN
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA ON [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.EMAIL.ID_UTENTE = [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.INCID LEFT OUTER JOIN
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.SEDI ON [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.ID_SEDE = [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.SEDI.INCID LEFT OUTER JOIN
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.TELEFONI ON [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.INCID = [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.TELEFONI.ID_UTENTE LEFT OUTER JOIN
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.UFFICI ON [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.ID_UFFICIO = [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.UFFICI.INCID ON
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.AZIENDE.INCID = [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.ID_AZIENDA
ORDER BY [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_COGNOME, [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA.S_NOME
GO
Msg 4104, Level 16, State 1, Line 18 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.EMAIL.ID_UTENTE" could not be
bound.
Msg 4104, Level 16, State 1, Line 18 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.INCID" could not be
bound.
Msg 4104, Level 16, State 1, Line 19 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.ID_SEDE" could not be
bound.
Msg 4104, Level 16, State 1, Line 19 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.SEDI.INCID" could not be bound.
Msg 4104, Level 16, State 1, Line 20 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.INCID" could not be
bound.
Msg 4104, Level 16, State 1, Line 20 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.TELEFONI.ID_UTENTE" could not be
bound.
Msg 4104, Level 16, State 1, Line 21 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.ID_UFFICIO" could not
be bound.
Msg 4104, Level 16, State 1, Line 21 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.UFFICI.INCID" could
not be bound.
Msg 4104, Level 16, State 1, Line 22 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.AZIENDE.INCID" could
not be bound.
Msg 4104, Level 16, State 1, Line 22 The multi-part
identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.ID_AZIENDA" could not
be bound.
Msg 4104, Level 16, State 1, Line 13 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_COGNOME"
could not be bound.
Msg 4104, Level 16, State 1, Line 13 The
multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_NOME" could not be
bound.
Msg 4104, Level 16, State 1, Line 13 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.TELEFONI.S_TEL" could not be
bound.
Msg 4104, Level 16, State 1, Line 14 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.SEDI.S_DESCR" could not be
bound.
Msg 4104, Level 16, State 1, Line 14 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_QT" could not be
bound.
Msg 4104, Level 16, State 1, Line 14 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.EMAIL.S_EMAIL" could not be
bound.
Msg 4104, Level 16, State 1, Line 15 The multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_DOMINIO" could not
be bound.
Msg 4104, Level 16, State 1, Line 15 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.UFFICI.S_DESCR" could
not be bound.
Msg 4104, Level 16, State 1, Line 15 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.AZIENDE.S_DESCR"
could not be bound.
Msg 4104, Level 16, State 1, Line 23 The
multi-part identifier
"ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_COGNOME" could not
be bound.
Msg 4104, Level 16, State 1, Line 23 The multi-part
identifier "ZILNNM10.IT.SUB.FZ221-IT-DBA_3.0.dbo.ANAGRAFICA.S_NOME"
could not be bound.
Disclaimer: This is not a solution to your problem, but it's a major step on getting there.
The error you get means that SQL Server can't find the identifiers you specified in your query. Since every identifier in your original query is a multi part identifier, it's hard to read and harder to debug, so I've aliased all your tables to simplify the query you posted.
Also, mixing left joins with right joins is a recipe for disaster, so I did my best to fix that. This query should not get rid of all the error messages you've got but it should minimize them and help you find the problems.
Also, I've removed the TOP 100 PERCENT and ORDER BY clause. See my comment for details.
So here is the simplified query, I hope it helps.
SELECT ANAGRAFICA.S_COGNOME + ' ' +
ANAGRAFICA.S_NOME AS UTENTE,
TELEFONI.S_TEL AS TEL,
SEDI.S_DESCR AS PIANO,
ANAGRAFICA.S_QT AS NETNAME,
EMAIL.S_EMAIL AS EMAIL,
ANAGRAFICA.S_DOMINIO AS DOMINIO,
UFFICI.S_DESCR AS SERVIZIO,
AZIENDE.S_DESCR AS AZIENDA
FROM [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.AZIENDE As AZIENDE
RIGHT JOIN
(
[ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.ANAGRAFICA As ANAGRAFICA
LEFT JOIN [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.EMAIL As EMAIL ON EMAIL.ID_UTENTE = ANAGRAFICA.INCID
LEFT JOIN [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.SEDI As SEDI ON ANAGRAFICA.ID_SEDE = SEDI.INCID
LEFT JOIN [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.TELEFONI As TELEFONI ON ANAGRAFICA.INCID = TELEFONI.ID_UTENTE
LEFT JOIN [ZILNNM10.IT.SUB].[FZ221-IT-DBA_3.0].dbo.UFFICI As UFFICI ON ANAGRAFICA.ID_UFFICIO = UFFICI.INCID
) ON AZIENDE.INCID = ANAGRAFICA.ID_AZIENDA

Copying DB to new production env using dokku pg-plugin

Moving from heroku to dokku / digital ocean, I've used pg_dump to copy the database into a file 'latest.dump' and using pg_restore to my local pg db and it worked properly. But when I try to run the dokku postegresql:restore command, it runs and I receive 'database restored' but there are many errors and none of the data is actually restored. Any suggestions for how to troubleshoot / what is causing the errors?
root#domain:~# dokku postgresql:restore db_name < dokku/db/latest.dump
ERROR: syntax error at or near "PGDMP"
LINE 1: PGDMP
id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: version character varying(255) NOT NULL
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: _time, early_l...
^
ERROR: syntax error at or near "_price"
LINE 1: _price, delivery_counter, credit_card, yrd_per) FROM stdin;
^
ERROR: syntax error at or near "ADD"
LINE 1: ADD CONSTRAINT adjustments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT clients_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT contacts_tables_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT deliveries_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT devices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT drivers_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT locations_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT materials_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT mixes_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT payments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT plants_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT products_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT statements_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT trucks_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT users_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT workdays_pkey PRIMARY KEY (id);
^
invalid command \
invalid command \
invalid command \�/x$Ր�8X~`�O`�����*a
�ЛU[2u^����ar���m��kU�"���!���c﬍,Llel��ˀ��u�ʚb[
invalid command \�n
invalid command \$�I�m�
ɤ�HK��
invalid command \�}�b����7�6�]D�x�����|��l�D�Y}�P��A�T�װLJ��.{�ۇ�{c�bܤ��
invalid command \2��h[�/!I��${�7�#lHhLD���dÄG#�P�rL���qtkU����Iܩ&$�i�I��=0!�
invalid command \��`.���y���,�{0B�z�f3�^��?q�
invalid command \W���WIJ����lQ�
invalid command \r�9�S܀�fk�
invalid command \螀ܠ��T��g���eXx{j��8����x�Xt6�
invalid command \~zʘ�Z���OiƘbl}#p�E��.�;א}{8I��b�]��Rf�1��0
invalid command \q�6|P
��o��j���I���V
^��S
invalid command \��(��D����a����B(�ϓ]n�~Љ��������W����
invalid command \$�a��s8�5g��:�=#�!^�L6�0mjO;3��/�Ei7��)�Xp�K�
invalid command \�����q�P�ZF��
ERROR: syntax error at or near ""
LINE 1: ��kη�>6�x�
E�����U����d�]T���&
��_E>p��k��In�~�...
^
invalid command \x�6�`YIk
invalid command \�Q��8�
<¼��njWڡ��
invalid command \դ�n�|��p�ҍ���gve�d�]�{�/Ó+�Q�.�NQ�s��z)`SI.��v�8�U��[ͮi�Z�������FU
invalid command \�M�>=���7�;��4�!y25�J�������E=��(�LS֜{�S�I�3;
invalid command \ʑ<�0b<��Jm��y�]��9�B���V(��#��?���{�m�]AVv3嘫�f�Q�X=���
invalid command \l�I�W.
invalid command \��i���Tc��^���
invalid command \�刄��+�u�
invalid command \([����&DrLL�NC�l���E�J��uR��c�HQ�e*e�e8�V?R/�y���O�S��.+c��7E�V5�K��ɵC'��
invalid command \�
invalid command \'�Ε]���[ޮ���h�J/RV=�'�v�7m�z�-�,���v]�X�����Z%�5��P�jYi�.�N,���[δ���v��1`���n�օ��h
invalid command \�Wb���'�B-62y��
invalid command \�������sl�Q�
ERROR: syntax error at or near "Lnܚ"
LINE 1: Lnܚ��H�f�2U�Q���"��C��4(+6a�0EF?�*:�'=��^�^i� �T�)�...
^
invalid command \#i�ě��(������g���ժ�`Q˅&�O{�F������%��u�(GEMW��0�����G���}1�8�u��rF�V4�Y4:�'�h���ݟ�M�8�Q�
invalid command \'g�7�Zo����#i���R��jY��u*%��E���ց��s��M�'�#�d��<9�?���&�Rd�v�TTj3B=>��]Y6DsT�hǃ���=w�D�M47��!2�B�%�f��)S�ʽJr���8;��].x^�Vv�ɸ7����'R��BG5��rMt�F��&���{�)�B�����_~����f��*���ۻLJ���wo�m�{|����.�����������w��e9󹭣�&g�Ə�lNQ�<|�6˙��u��f��p��40�1g]�0ő�թ��-+�M��r����+���e�+�i���s݂�����b��y�ݾy>���S��m�2nUǨ���x[v�vخ�yec�h3[-}����N�s��:^�p���%�ʑ�I�ŸO������5Ģ!Bj�h��
ERROR: syntax error at or near "2"
LINE 1: 2^͗i��u� ���U�9zD>����(���q�ϫCw��O��6Q[D��...
^
invalid command \��Q%�,~�
invalid command \S��C�
�
ERROR: syntax error at or near "�3��"
LINE 1: �3��� ��0� V�[�� �Bz2K�W�1�X�:��|E{2� D���+sQ�...
^
ERROR: syntax error at or near "˭�y��"
LINE 1: ˭�y��
���4�:��Rz�g+�����ɲ�U+1�V
�"�
^
invalid command \Y8��t��.
invalid command \�;�K
ERROR: syntax error at or near "Y��"
LINE 1: Y��]�hI?w}8�U��C�K��`2c���/��]*NTG+�����
&ai��-w...
^
invalid command \���:vH*a7���g�7uZ����ƴ5j8���
invalid command 0��M���-U0�9�+���b,R�
ERROR: syntax error at or near "��9�"
LINE 1: ��9�
�UD6q�)�LѴ��L�I�U��t�g��t�;xVM΁9����&��o����OO...
^
invalid command \ܯո�i$0��2�i�
invalid command \�0�2�$�XMф���Y�r�i�7�k�e����������~z}�"�&��H(�
invalid command \Z�3��F�6t�
invalid command \O�k�i�|�bJ�+�$ٝHO�j_�ƲF���S�R���Z�
invalid command \sȗ�������Zu�/�>ddz��Mr���G��Y���wi�����p��[����Cw�#�&�K���$j�w�|wa�����
invalid command \�d���j���
invalid command \[9ד���sPFo���c�S��>���hG>GOߥ��;��۞Z��`�6�Aa
invalid command \���g<Y��I#��F؁R��V�
invalid command \w��枎�S�%����=uR��7
invalid command \�k'�#��li��P4��F�I��^E��߷��7
invalid command \��onC�!�CX�;1����s�yFdy2�G���'S�82��
invalid command \��V���Bh{�
invalid command \��s���`
invalid command \�N&h�:31$�Mul+��k��<.�b�Z���g.�YUn1^�u�"𠒑GƇ�#Ʈ�.�>ߙ�h
invalid command \�xIrK�2
ERROR: syntax error at or near "�"
LINE 1: ��I��}*X�L����_���%��~8gt�ȃ�l�BZ,˹��s]��d�����h�e�a/
^
invalid command \k�
Nj��#��#���79M��L�|�o�6Lᘪ��[&�[(��*�
ERROR: syntax error at or near "�"
LINE 1: �
^
-----> db_name database restored
I believe a similar problem happened to me when trying to complete a similar task. You need to use a .sql file when uploading the database to your new stack. By default, Heroku gives you a .dump file. What worked for me was copying the database to my local development pg db using the .dump file and then using that to generate a .sql file which I pushed to my new app.
This worked for me:
pg_restore -O latest.dump | dokku postgresql:restore <db_name>
found here: https://github.com/Kloadut/dokku-pg-plugin/issues/52