![]() Deleting the student_id column should also lead to deleting the SEQUENCE object associated with it.As a sequence always generates a non-null integer value, the column student_id will be assigned with the NOT NULL constraint.It assigns the default value of the “student_id” column to the next value of that sequence. When a table with a SERIAL column called “student_id” is created in PostgreSQL, the system automatically generates a new SEQUENCE object for that column. ![]() PostgreSQL executes the above-mentioned internal queries when declaring any column of type SERIAL in a table. Some of them are as follows: CREATE SEQUENCE educba_student_id_seq CREATE TABLE educba (student_id integer NOT NULL DEFAULT nextval('educba_student_id_seq'), name VARCHAR(100)) ALTER SEQUENCE educba_student_id_seq OWNED BY educba.student_id Internally, PostgreSQL executes a series of commands. ![]() When we declare the column named “student_id” of type SERIAL in the table creation query for the “educba” table in the following way.Ĭode: CREATE TABLE educba(student_id SERIAL,name VARCHAR(100))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |