Reputation: 1
CREATE TABLE Employee (
emp_id SMALLINT PRIMARY KEY,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR (20),
birth_date DATE NOT NULL,
sex VARCHAR (20),
salary INT,
super_id INT,
branch_id SMALLINT
);
ALTER TABLE Employee
ALTER COLUMN sex VARCHAR(1);
I am a beginner so go easy on me, please. I am not able to understand what am I doing wrong. error:
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 'VARCHAR(1)' at line 2
Upvotes: 0
Views: 86
Reputation: 24568
in mysql you need to use MODIFY
ALTER TABLE Employee
MODIFY COLUMN sex VARCHAR(1);
by the way if you already have data in your table , any value more than 1 character in sex column will be truncated , so you have to take care of that before altering column length
Upvotes: 1