Difference between revisions of "Creating tables in SQL Server"
From MyWiki
Line 3: | Line 3: | ||
Foreign constraint prevents invalid data from being entered into the foreign key column. The foreign key value must be one of the values contained in the table it references. | Foreign constraint prevents invalid data from being entered into the foreign key column. The foreign key value must be one of the values contained in the table it references. | ||
+ | |||
+ | Creating a table using sql<br> | ||
+ | |||
+ | Create Table tblGender | ||
+ | { | ||
+ | ID int NOT NULL Primary Key, | ||
+ | Gender nvarchar(50) NOT NULL, | ||
+ | |||
+ | |||
+ | |||
+ | } |
Revision as of 00:49, 3 September 2015
Alter table table1 add constraint <name of constraint>
FOREIGN KEY (<column>) references table2 (<primary key column>)
Foreign constraint prevents invalid data from being entered into the foreign key column. The foreign key value must be one of the values contained in the table it references.
Creating a table using sql
Create Table tblGender { ID int NOT NULL Primary Key, Gender nvarchar(50) NOT NULL,
}