Defining a Primary Key for a Table(该内存表DataTable 设置主键)
2008-05-30 21:23
405 查看
A database table commonly has a column, or group of columns, that uniquely identifies each row in the table. This identifying column or group of columns is called the primary key.
一个数据表都有一个或者是若干个列,而每个表都可以有唯一标识列的字段,这些能够标识字段的列就是所谓的主键。
When you identify a single DataColumn as the PrimaryKey for a DataTable, the table automatically sets the AllowDBNull property of the column to false and the Unique property to true. For multiple-column primary keys, only the AllowDBNull property is automatically set to false.
当你为确定一个列为数据表的主键的时候,表会自动为该列设置非空的属性。如果主键的内容涵盖多个列,那么这些列也都为非空。
The PrimaryKey property of a DataTable receives as its value an array of one or more DataColumn objects, as shown in the following examples. The first example defines a single column as the primary key.
例子:
workTable.PrimaryKey = new DataColumn[] {workTable.Columns["CustLName"], workTable.Columns["CustFName"]};
一个数据表都有一个或者是若干个列,而每个表都可以有唯一标识列的字段,这些能够标识字段的列就是所谓的主键。
When you identify a single DataColumn as the PrimaryKey for a DataTable, the table automatically sets the AllowDBNull property of the column to false and the Unique property to true. For multiple-column primary keys, only the AllowDBNull property is automatically set to false.
当你为确定一个列为数据表的主键的时候,表会自动为该列设置非空的属性。如果主键的内容涵盖多个列,那么这些列也都为非空。
The PrimaryKey property of a DataTable receives as its value an array of one or more DataColumn objects, as shown in the following examples. The first example defines a single column as the primary key.
例子:
workTable.PrimaryKey = new DataColumn[] {workTable.Columns["CustLName"], workTable.Columns["CustFName"]};
相关文章推荐
- mysql主键设置成auto_increment时,进行并发性能测试出现主键重复Duplicate entry 'xxx' for key 'PRIMARY'
- mysql主键设置成auto_increment时,进行并发性能測试出现主键反复Duplicate entry 'xxx' for key 'PRIMARY'
- 【iOS开发-60】案例学习:多组数据的tableView设置、增加右侧组索引、多层数据模型设置以及valueForKeyPath
- 【iOS开发-60】案例学习:多组数据的tableView设置、添加右側组索引、多层数据模型设置以及valueForKeyPath
- SQLite主键自增需要设置为integer PRIMARY KEY
- MySQL主键重复问题解决 Duplicate entry '787192513' for key 'PRIMARY'
- MySQL如何创建主键?Alter table add PRIMARY KEY的用法和例子
- EJB3: Mapping of 1-to-1 relationships when primary key in the source table is also a foreign key for the target entity
- 删除主键: Alter table tabname drop primary key(col)
- LOV for Editable Primary Key in ADF Table Problem
- MySQL如何创建主键?Alter table add PRIMARY KEY的用法和例子
- MVC3 Model中有两个主键时出现:Unable to determine composite primary key ordering for type错误的解决办法
- 增加字段改为主键后:1062-Duplicate entry '' for key 'PRIMARY'
- ORACLE新增主键问题【CREATE PRIMARY KEY AFTER CREATED A TABLE】
- mysql 主键重复问题解决 Duplicate entry '787192513' for key 'PRIMARY'
- Hibernate自增主键因重复导致报错“Duplicate entry 'xxx' for key 'PRIMARY'”
- PLSQL Tools for query primary key and foreign key of a table
- 重建分区表主键 - Recreate Primary Key on a partition table
- MySQL如何创建主键?Alter table add PRIMARY KEY的用法和例子
- 如何让oracle里面的主键自动递增 autoincrement primary key for oracle