Numeric ID for transfer codes
Hello!, I wanted to know if with xata I had the possibility of creating a column that has unique numbers and that the numbers are created by themselves as they are created, like an ID field but personalized
7 Replies
Hi there! You can use
SERIAL
to add a column that will auto increment and stay unique. I created a table called test
in my own environment then ran the following query in the UI:
If you return to the table and add records you'll see that the id_serial
column is automatically updated with a unique id. The only caveat is that you can't use the name id
Thanks!, Your answer was very helpful to me
invalid SQL: unsupported statement [ALTER TABLE] on strict level, see https://xata.io/sql-support for the support matrix
The ui throw me this error
Connect to Postgres
Learn how to connect to Postgres directly via the wire protocol
Is your database enabled for direct Postgres access? If so, does the database have the native sql table option enabled?
Ah, I can see that your databases are not enabled for direct postgres access. Unfortuntately, running such statements is not supported on non-postgres enabled databases.
And is there any other type of solution that I can carry out for the problem I have?
I'm afraid this is one of the limitations of a non-postgres-enabled database. Your other option is to migrate your database to a postgres-enabled database (the option can only be toggled at db creation)
