Changing starting ticket number - please help!

Hi, i’m trying to change the starting ticket number to a higher number.
I have a RT 4.4.3 brand new installation on a Centos 7 using the Centos installation guide from the wiki.

I’m issuing these commands:

sudo -u postgres psql - to enter the posgres shell and enter the password to authenticate

then I issue

postgres=# SELECT setval(‘tickets_id_seq’, 20800);

and get this error

ERROR: relation “tickets_id_seq” does not exist
LINE 1: SELECT setval(‘tickets_id_seq’, 20800);

Would you guys be able to help interpret this?

I’m not a postgres user, but do you not have to select the RT4 database before running the select? Otherwise you’ll be trying to do it in whatever default database postgres has that doesn’t have RT’s ticket_id_seq.

Thanks, looking at the installation guide, it looks like I created this database - initdb.

How would I enter into this db to issue the command I need?

A quick google search tells me its


where NAME_OF_RT_DATABASE is whatever you called your RT database during installation (usually rt4).

Thanks. The database turned out to be rt4. I got in to the database with \c rt4 command. Then I listed tables in the database with \dt command. The tickets table was in the list. Then I listed all columns of the tickets table with \d tickets command. It showed me the id record which is the ticket number:

Table “”
Column | Type | Modifiers


id | integer | not null default nextval(‘tickets_id_seq’:
effectiveid | integer | not null default 0
ismerged | smallint |
queue | integer | not null default 0
type | character varying(16) |

So it looks like the ‘tickets_id_seq’ is there. But when I issue this command

SELECT setval(‘tickets_id_seq’, 20800);

I still get the same result

rt4=# SELECT setval(‘tickets_id_seq’, 20800);
ERROR: column “‘tickets_id_seq’” does not exist
LINE 1: SELECT setval(‘tickets_id_seq’, 20800);

What am I doing wrong here?

Any idea?..

Are those the quotes you are using around ‘ticket_id_seq’? I believe smart quotes will make the operation fail.

I don’t know, it’s how it’s showed in the instructions I got from the wiki. How should I put it then?


I think you misread the result of your queries. The first column is “id”, not " tickets_id_seq". Instead, “tickets_id_seq” is a sequence, that in database jargon is something that establishes which number to assign next.

So if you want to try to set a higher starting number, you should write:

SELECT setval(‘id’, 20800);

Note however that the DBMS may not allow you to do it. I am a database administrator but I have very little experience with postgres unfortunately, so I’m unable to offer you a better solution.


What do you get for this query in the rt4 database:

SELECT pg_get_serial_sequence('Tickets', 'Id');

That should show the actual sequence name attached to the Id column in the Tickets table.

SELECT setval(‘tickets_id_seq’, 20800);

Worked fine for me, the next ticket I made was #20801.


Could you show me step by step exactly what commands you enter to get to the database level and to get to issue this command. Maybe I’m missing something.

I’ll try that in a few.

psql postgres
psql (10.5)
Type "help" for help.

postgres=# \c rt44
You are now connected to database "rt44" as user "craigkaiser".
rt44=# SELECT setval('tickets_id_seq', 20800);
(1 row)


I want to try what you did here with the psql postgres command but I can’t authenticate. I enter the postgres password I created during the installation and I still get this:

psql: FATAL: password authentication failed for user “root”

But when I issue this command - sudo -u postgres psql
I can authenticate into the postgres with the password I created during installation.

What’s the difference between these commands?

I finally got it to work!

Steps I did:

[root@server ~]# su - postgres
Last login: Tue Nov 6 03:07:40 UTC 2018 on pts/0
Last failed login: Thu Nov 8 04:34:44 UTC 2018 from on ssh:notty
There were 30 failed login attempts since the last successful login.
-bash-4.2$ psql
psql (9.2.24)
Type “help” for help.

postgres=# \c rt4
You are now connected to database “rt4” as user “postgres”.
rt4=# SELECT setval(‘tickets_id_seq’, 20800);

(1 row)

It worked that way.

Thank you guys for all your help. I really appreciate it and hope this can be useful for someone else.


I finally got it to work!


Sorry if I posted misleading information. Looking at the error message (" ERROR: column “‘tickets_id_seq’” does not exist") I thought that that command had to be run against the column, not the sequence itself.

Thank you for sharing your solution to the problem!