Computed Columns

In MSSQL you can create a table with a computed column, like this...

CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters.
( [at] CubeLength decimal(4,1), [at] CubeWidth decimal(4,1),
[at] CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( [at] CubeLength * [at] CubeWidth * [at] CubeHeight )
END

CREATE TABLE Bricks
(
BrickPartNmbr int PRIMARY KEY,
BrickColor nchar(20),
BrickHeight decimal(4,1),
BrickLength decimal(4,1),
BrickWidth decimal(4,1),
BrickVolume AS
(
dbo.CubicVolume(BrickHeight,
BrickLength, BrickWidth)
)
)

Is there an equivalent in MySQL beside views, stored procedures or
calculating it in a query?

I'm not trying to implement it; I'm just curious.
peterloh [ Fr, 22 September 2006 01:36 ] [ ID #1475121 ]

Re: Computed Columns

peterloh [at] gmail.com wrote:
> Is there an equivalent in MySQL beside views, stored procedures or
> calculating it in a query?

No, there is no declarative support for computed fields in MySQL.

Regards,
Bill K.
Bill Karwin [ Fr, 22 September 2006 07:21 ] [ ID #1475122 ]
Datenbanken » mailing.database.mysql » Computed Columns

Vorheriges Thema: Unknown column 'NAN' in 'field list'
Nächstes Thema: Exporting accented characters