May 15, 2003 at 7:43 am
in my concise 229 book, to define a primary key as follows:
create table table1
abc1 int primary key
...
and another way
ab1 int
constraint table_pk primary key(abc1)
so what is "table_pk"?
May 15, 2003 at 8:12 am
table_pk is the primary key constraint name. In this case they are using the table name plus "_PK" to make up the name. Therefore if your table was called tblEmployee, the Primary key of that table would be "tblEmployee_pk" using their format. If a constraint name is not specified, the database will automatically generate one (as in the first instance).
May 16, 2003 at 7:46 am
The _pk is what is known as a "naming convention". It identifies that name as a primary key. Other conventions are udf_functionname. udf is short for user defined function. sp is stored procedure. ETC.
-SQLBill
June 14, 2003 at 6:50 am
Primary Keys are stored as constraint objects within a database. All objects must have names, as mentioned in a previous post, the names should be meaningful and follow a naming convention. If you are bored, run the following script:
use northwind
select * from sysobjects where xtype = 'pk'
It will list all the PKs in the northwind database.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply