我在 MSSQL 中创建了表脚本:
CREATE TABLE [dbo].[Address](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Street] [nvarchar](100) NOT NULL,
[BuildingNumber] [nvarchar](15) NULL,
[ApartmentNumber] [nvarchar](15) NULL,
[City] [nvarchar](100) NOT NULL,
[Country] [nvarchar](250) NULL,
[Postcode] [nvarchar](15) NULL,
**[Search] AS (((((((([Street]+' ')+[BuildingNumber])+' ')+isnull([ApartmentNumber],''))+' ')+[Postcode])+' ')+[City]) PERSISTED,**
CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
如何使用 PostgreSQL 中其他列的值创建“搜索”列?我尝试设置 DEFAULT 值,但 Postgresql 不允许 mi 使用列名创建默认值。