Reputation: 1281
I have ported a database to a new laptop by using an sql dump from the old computer and then executing this dump on the new computer. Thea data was copied correctly, and all the SQL statements regarding the tables work perfectly.
For creating new relations i need to know the values of some of the sequences in the DB:
italo=> \ds
List of relations
Schema | Name | Type | Owner
--------+--------------------------+----------+-------
public | Conjugation_conjType_seq | sequence | italo
public | Conjugation_idConj_seq | sequence | italo
public | NounItalian_idNounIt_seq | sequence | italo
public | VerbItalian_idVerbIt_seq | sequence | italo
public | times_idTime_seq | sequence | italo
(5 rows)
When i use currval()
in a select statement i get an error:
italo=> SELECT currval('VerbItalian_idVerbIt_seq');
ERROR: relation "verbitalian_idverbit_seq" does not exist
LINE 1: SELECT currval('VerbItalian_idVerbIt_seq');
When i look at a sequence in phppgadmin
, i get the same error message about the missing relation followed by a column view of the sequence. The error message reads
SQL error:
ERROR: relation "public.verbitalian_idverbit_seq" does not exist
In statement:
SELECT pg_catalog.has_sequence_privilege('public.VerbItalian_idVerbIt_seq','SELECT,USAGE')
Name | Start value | Last value | Increment by | Max value | Min value | Cache value | Log count | Can cycle? | Will increment last value before returning next value (is_called)?
VerbItalian_idVerbIt_seq | 100 | | 1 | 9223372036854775807 | 1 | 1 | | No | No
Alter Set value Increment value Restart Reset Show all sequences
(the values for "Last value" and "Log count" are empty)
When i click on "Set value", i can enter a value for "Last value", and there is small message "Sequence value set.", but in the view nothing has changed.
The behavior is the same for all 5 sequences.
What do i have to do to fix my sequences so that i can use currval()
on them?
EDIT: when i create a new sequence from scratch, it behaves as expected
Upvotes: 1
Views: 1078
Reputation: 127367
Because of the usage of UpperCase characters, you have to use double quotes " around the identifiers:
SELECT currval('"VerbItalian_idVerbIt_seq"');
Upvotes: 1