![]() ![]() ![]() Its name is generated by the name of the current table, an underscore (‘ _’), the column name, another underscore (‘ _’), and ‘ fkey’. In our result table above, you can see two PRIMARY KEY names (type ‘ p’) – one by the name country_pkey in the country table and another by the name student_pkey in the student table.Ī FOREIGN KEY is indicated by the constraint type ‘ f’. The PRIMARY KEY is named by default with the table name, an underscore (‘ _’), and ‘ pkey’. In PostgreSQL, the default constraint types are p, f, u, and c. How are the default names for constraints generated? However, we don’t specify the names for these constraints, so they are named by default in PostgreSQL. When we create our tables, we set constraints for some columns. Let’s display how PostgreSQL names the constraints of these tables by default. ![]() Name varchar(100) NOT NULL DEFAULT 'unknown',įOREIGN KEY(country_id) references country(id) In our database, we create two tables, country and student, with the following constraints: PRIMARY KEY (the column id in the tables country and student), FOREIGN KEY (the column country_id in the table student), DEFAULT (the column name in the table student), UNIQUE (the column name in the table country and the column personal_number in the table student), and CHECK (the column age in the table student). You want to know the default names of constraints in a table in PostgreSQL. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |