SERIAL data type allows you to automatically generate unique integer numbers (IDs, identity, auto-increment, sequence) for a column. Quick Example: -- Define. FAQ: Using Sequences in PostgreSQL. Many of the questions asked in #postgresql revolve around using sequences in PostgreSQL. To avoid answering the same questions again and again, I thought it would be worthwhile to summarize the basic steps involving in using sequences in PostgreSQL. ![]() This is not a pgAdmin feature but that of PostgreSQL. If you check your table from an other client (eg. Psql) you will see the exact same column definition. Why is it so? The data types serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases). In the current implementation, specifying: CREATE TABLE tablename ( colname SERIAL ); is equivalent to specifying: CREATE SEQUENCE tablename_colname_seq; CREATE TABLE tablename ( colname integer NOT NULL DEFAULT nextval('tablename_colname_seq') ); ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname; It is always useful to consult the. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |