我在sql「empleado」中有一個表,從中可以計算出我想要的屬性之一。如何在PosgreSQL中創建計算屬性
這是代碼:
create table empleado (
dni char(9) not null,
contrasena varchar (20) not null,
nombre varchar (30) not null,
apellidos varchar (60) not null,
direccion varchar (80) not null,
telefono char (9) not null,
tipo varchar(30) not null,
fechaIngreso date not null,
antiguedad Integer as getdate()-fechaIngreso,
salario real not null check (salario >0),
primary key (dni)
);
屬性安蒂格達德必須是實際的日期 - 「fechaIngreso」 以天爲單位。我怎麼能解決這個問題?
謝謝
您使用的是MySQL還是SQL Server? MySQL不支持'getdate()',計算列或檢查約束。請適當地標記你的問題。 –
我使用的是ProsgreSQL,我認爲它是mysql – vps
。 。 Postgres不同於MySQL和SQL Server。 –