SQL CREATE ALTER DROP TABLE: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:
|-
|-
|}
|}
If the <code>TEMPORARY</code> keyword is used, the created table will be [[SQL#Temporary_Table|temporary]] instead of [[SQL#Permanent_Table|permanent]].


=<tt>ALTER</tt>=
=<tt>ALTER</tt>=

Revision as of 17:54, 23 May 2024

Internal

Overview

CREATE

CREATE [TEMPORARY] TABLE person 
( id smallint, 
  name varchar(30) NOT NULL, 
  CONSTRAINT pk_person PRIMARY KEY (id)
);
PostgreSQL MySQL

If the TEMPORARY keyword is used, the created table will be temporary instead of permanent.

ALTER

ALTER TABLE person [...]

Add/Remove a Column

ALTER TABLE person ADD COLUMN birthday DATE;
PostgreSQL MySQL

DROP

DROP TABLE person [...]
PostgreSQL MySQL

Features

AUTO_INCREMENT

AUTO_INCREMENT