Rename column

From SQLZoo

Rename column

schema:scott
DROP TABLE a
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);

ALTER TABLE a CHANGE x y INTEGER;
SELECT * FROM a
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);

ALTER TABLE a RENAME COLUMN x TO y;
SELECT * FROM a
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);

ALTER TABLE a RENAME COLUMN x TO y;
SELECT * FROM a
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);
ALTER TABLE a RENAME COLUMN x TO y;
USE scott;
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);

sp_rename 'a.x', 'y', 'COLUMN';
SELECT * FROM a;
Not possible
CREATE TABLE a(x INTEGER);
INSERT INTO a VALUES (2);

ALTER TABLE a RENAME COLUMN x TO y;
SELECT * FROM a
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: digitalocean-sqlzoo