我正在尝试将表中一列的数据类型从biginteger更改为varchar。
myproject-# \d+ product_awbstock
Table "public.product_awbstock"
Column | Type | Modifiers | Storage | Description
-------------------+--------------------------+-----------+---------+-------------
airwaybill_number | bigint | not null | plain |
used | boolean | not null | plain |
created | timestamp with time zone | not null | plain |
modified | timestamp with time zone | not null | plain |
Indexes:
"product_awbstock_pkey" PRIMARY KEY, btree (airwaybill_number)
"product_awbstock_used" btree (used)
我正在使用此查询,也会给出错误。
alter table product_awbstock ALTER COLUMN airwaybill_number TYPE varchar(15);
错误:外键约束 “awbstock_id_refs_airwaybill_number_d438187b”无法实施
详细信息:键列“awbstock_id”和“airwaybill_number”属于 不兼容的类型:bigint和字符变化。
答案 0 :(得分:2)
你应该:
$Machines = "xxx", "yyyy", "zzz"
Get-WmiObject Win32_LogicalDisk -ComputerName $Machines -Filter "DeviceID='C:'" |
Select-Object pscomputername, @{Name="Size GB";Expression={ "{0:N2}" -f ($_.Size / 1GB)}}, @{Name="Free GB";Expression={ "{0:N2}" -f ($_.FreeSpace / 1GB) }}
ALTER TABLE product_awbstock DROP CONSTRAINT product_awbstock_pkey;
ALTER TABLE ??? DROP CONSTRAINT awbstock_id_refs_airwaybill_number_d438187b;
ALTER TABLE product_awbstock ALTER COLUMN airwaybill_number TYPE varchar(15);
ALTER TABLE ??? ALTER COLUMN airwaybill_id TYPE varchar(15);
ALTER TABLE product_awbstock ADD CONSTRAINT product_awbstock_pkey PRIMARY KEY (airwaybill_number);