Ashok
Ashok

Reputation: 13

How to create a Generated Column in MYSQL Version(6.0.11-alpha-community)

I create a table with Generated Column in MYSQL Version(6.0.11-alpha-community)

Like below I modified the structure of the Generated Column

One :

CREATE TABLE tbl_MAE_Customers(
  ID INT AUTO_INCREMENT PRIMARY KEY, 
  CustomerName VARCHAR(30), 
  PhoneNmbr VARCHAR(15), 
  Email VARCHAR(30),
  TCSShares INT,
  InfosysShares INT, 
  TechmShares INT, 
  TotalShares INT GENERATED ALWAYS AS (TCSShares+InfosysShares+TechmShares), 
  Remarks VARCHAR(200)
)

Two :

CREATE TABLE tbl_MAE_Customers(
  ID INT AUTO_INCREMENT PRIMARY KEY, 
  CustomerName VARCHAR(30), 
  PhoneNmbr VARCHAR(15), 
  Email VARCHAR(30),
  TCSShares INT,
  InfosysShares INT, 
  TechmShares INT, 
  TotalShares INT  AS (TCSShares+InfosysShares+TechmShares),
  Remarks VARCHAR(200)
)

Third :

CREATE TABLE tbl_MAE_Customers(
  ID INT AUTO_INCREMENT PRIMARY KEY,
  CustomerName VARCHAR(30),
  PhoneNmbr VARCHAR(15),
  Email varchar(30),
  TCSShares int,
  InfosysShares int, 
  TechmShares int, 
  TotalShares  as (TCSShares+InfosysShares+TechmShares), 
  Remarks varchar(200)
)

This many ways I try to modify the structure of the Generated Column and when I execute the query I'm getting this below error:

Query: CREATE TABLE tbl_MAE_Customers(ID INT AUTO_INCREMENT PRIMARY KEY, CustomerName VARCHAR(30), PhoneNmbr VARCHAR(15), Email varchar...

Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GENERATED ALWAYS as (TCSShares+InfosysShares+TechmShares), Remarks varchar(200))' at line 2

Execution Time : 0 sec Transfer Time : 0 sec Total Time : 0.001 sec

I'm new to MYSQL.

Suggest me how to achieve this with out an any error.

Upvotes: 0

Views: 239

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562951

You're using an alpha version of MySQL 6.0 from May 2009. The 6.0 branch never made it out of alpha status. It was canceled because of code performance issues. It's honestly surprising you could even find a copy of it!

Further development of MySQL continued, but the version became 5.6. I know it's confusing, but 5.6 is more advanced than 6.0. But even 5.6 is so old now that it is past its end of life.

The GENERATED syntax for expression columns was introduced in MySQL 5.7. MySQL 6.0 and 5.6 do not support generated columns. You will have to use a current version to get support for that feature.

Upvotes: 2

Related Questions