SQL CREATE ALTER DROP VIEW: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * SQL * SQL Data Types =Overview= =<tt>CREATE</tt>= <syntaxhighlight lang='sql'> CREATE TABLE person ( id smallint, name varchar(30) NOT NULL, CONSTRAINT pk_person PRIMARY KEY (id) ); </syntaxhighlight> :{| class="wikitable" style="text-align: left;" |- | PostgreSQL || MySQL |- |} =<tt>ALTER</tt>= <syntaxhighlight lang='sql'> ALT...")
 
Line 6: Line 6:
=<tt>CREATE</tt>=
=<tt>CREATE</tt>=
<syntaxhighlight lang='sql'>
<syntaxhighlight lang='sql'>
CREATE TABLE person
CREATE TABLE cust_view AS
( id smallint,  
SELECT id, name, address FROM customer;  
  name varchar(30) NOT NULL,  
  CONSTRAINT pk_person PRIMARY KEY (id)
);
</syntaxhighlight>
</syntaxhighlight>
:{| class="wikitable" style="text-align: left;"
:{| class="wikitable" style="text-align: left;"
|-
|-
| [[PostgreSQL_DDL_Operations#Create_a_Table|PostgreSQL]] || [[MySQL_DDL_Operations#Create_Table|MySQL]]
| [[PostgreSQL_DDL_Operations#Create_a_View|PostgreSQL]] || [[MySQL_DDL_Operations#Create_View|MySQL]]
|-
|-
|}
|}

Revision as of 17:06, 23 May 2024

Internal

Overview

CREATE

CREATE TABLE cust_view AS 
SELECT id, name, address FROM customer;
PostgreSQL MySQL

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