Difference between revisions of "ALTER TABLE ... DROP COLUMN"

From SQLZOO
Jump to: navigation, search
 
(One intermediate revision by one user not shown)
Line 12: Line 12:
 
</source>
 
</source>
  
<source lang='sql' class='def'>ALTER TABLE a DROP COLUMN y
+
<source lang='sql' class='def'>ALTER TABLE a DROP COLUMN y;
 +
SELECT * FROM a;
 
</source>
 
</source>
<source lang='sql' class='def e-sybase'>ALTER TABLE a DROP y
+
<source lang='sql' class='def e-sybase'>ALTER TABLE a DROP y;
 +
SELECT * FROM a;
 
</source>
 
</source>
  
 
<div class="ecomm e-oracle" style="display: none">
 
<div class="ecomm e-oracle" style="display: none">
<a href="http://sqlzoo.napier.ac.uk/big/B/s/a/statements_32a.htm#2103928">ALTER TABLE t DROP COLUMN c</a>
+
[http://sqlzoo.napier.ac.uk/big/B/s/a/statements_32a.htm#2103928 ALTER TABLE t DROP COLUMN c]
 
</div>
 
</div>
 
<div class="ecomm e-db2" style="display: none">
 
<div class="ecomm e-db2" style="display: none">
<a href="https://aurora.vcu.edu/db2help/db2s0/frame3.htm#sqls0604">
+
[https://aurora.vcu.edu/db2help/db2s0/frame3.htm#sqls0604  
ALTER TABLE documentation.</a><br/>
+
ALTER TABLE documentation.]<br/>
 
DB2 seemingly does not permit this operation - any help would be appreciated.
 
DB2 seemingly does not permit this operation - any help would be appreciated.
 
</div>
 
</div>
 
<div class="ecomm e-sybase" style="display: none"> Sybase doesn't like the COLUMN keyword.</div>
 
<div class="ecomm e-sybase" style="display: none"> Sybase doesn't like the COLUMN keyword.</div>
<div class="ecomm e-postgres" style="display: none"><a href="http://www.ca.postgresql.org/users-lounge/docs/7.0/user/sql-altertable.htm">ALTER TABLE</a></div>
+
<div class="ecomm e-postgres" style="display: none">[http://www.ca.postgresql.org/users-lounge/docs/7.0/user/sql-altertable.htm ALTER TABLE]</div>
  
 
</div>
 
</div>
 
{{CREATE and DROP ref}}
 
{{CREATE and DROP ref}}

Latest revision as of 14:04, 17 July 2012

Delete a column from a table

schema:scott

This is in the SQL standard ALTER TABLE

DROP TABLE a
CREATE TABLE a(x INTEGER, y INTEGER);
INSERT INTO a VALUES (1,2);
ALTER TABLE a DROP COLUMN y;
SELECT * FROM a;
ALTER TABLE a DROP y;
SELECT * FROM a;
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense