Difference between revisions of "Rename column"

From SQLZOO
Jump to: navigation, search
(Created page with "Rename column <div class='ht'> <div class=params>schema:scott</div> <div> </div> <source lang=sql class='tidy'>DROP TABLE a</source> <source lang=sql class='setup'>CREATE TAB...")
 
 
(One intermediate revision by one user not shown)
Line 6: Line 6:
  
 
<source lang=sql class='tidy'>DROP TABLE a</source>
 
<source lang=sql class='tidy'>DROP TABLE a</source>
<source lang=sql class='setup'>CREATE TABLE t_test
+
<source lang=sql class='setup'></source>
(a INTEGER NOT NULL PRIMARY KEY
+
,b VARCHAR(10)
+
)</source>
+
  
<source lang='sql' class='def e-mysql'>DROP TABLE a;
+
<source lang='sql' class='def e-mysql'>
 
CREATE TABLE a(x INTEGER);
 
CREATE TABLE a(x INTEGER);
 
INSERT INTO a VALUES (2);
 
INSERT INTO a VALUES (2);

Latest revision as of 10:06, 17 July 2012

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
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense