Define primary key in table creation : sp_helpindex « System « SQL Server / T-SQL






Define primary key in table creation

 


3> CREATE TABLE customer
4> (
5> cust_id      int          IDENTITY  NOT NULL,
6> cust_name    varchar(30)  NOT NULL,
7> CONSTRAINT customer_PK PRIMARY KEY (cust_id)
8> )
9> GO
1>
2> EXEC sp_helpindex customer
3> GO
index_name                                                                                                                       index_description
                                                                                                                                            index_keys











-------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------
customer_PK                                                                                                                      clustered, unique, primary key located on PRIMARY
                                                                                                                                            cust_id











1>
2> drop table customer;
3> GO
1>

 








Related examples in the same category