为以下 table 创建唯一 ID 列
Creating a unique ID column for the following table
我想为以下 table 生成唯一 ID 列:
我不确定该怎么做,因为每一列都有空值
FromCompany Container Numbers ToCompany Location
DISCOVERY HALU 330308 5 MAGNA CHARGE St-Laurent
ATSU 827944 0 LEEZA DIST.
4
COLUMBIA CAIU 807457 3 La Cie Canada Baie D'Urfe
6
0
为您的 table 创建一个标识列。
Alter Table t
Add Id Int Identity(1, 1)
更全面的例子
create table t(col1 int);
GO
✓
insert into t values (1), (2), (5)
GO
3 rows affected
Alter Table t
Add Id Int Identity(1, 1)
GO
✓
select * from t
GO
col1 | Id
---: | -:
1 | 1
2 | 2
5 | 3
db<>fiddle here
我想为以下 table 生成唯一 ID 列:
我不确定该怎么做,因为每一列都有空值
FromCompany Container Numbers ToCompany Location
DISCOVERY HALU 330308 5 MAGNA CHARGE St-Laurent
ATSU 827944 0 LEEZA DIST.
4
COLUMBIA CAIU 807457 3 La Cie Canada Baie D'Urfe
6
0
为您的 table 创建一个标识列。
Alter Table t
Add Id Int Identity(1, 1)
更全面的例子
create table t(col1 int); GO
✓
insert into t values (1), (2), (5) GO
3 rows affected
Alter Table t Add Id Int Identity(1, 1) GO
✓
select * from t GO
col1 | Id ---: | -: 1 | 1 2 | 2 5 | 3
db<>fiddle here