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...")
 
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
* [[SQL#CADV|SQL]]
* [[SQL#CADV|SQL]]
* [[SQL_Data_Types#Overview|SQL Data Types]]
* [[SQL_Data_Types#Overview|SQL Data Types]]
=TODO=
<font color=darkkhaki>TO PROCESS: https://learning.oreilly.com/library/view/learning-sql-3rd/9781492057604/ch14.html</font>
=Overview=
=Overview=
{{Internal|SQL#Virtual_Table_(View)|Virtual Table (View)}}


=<tt>CREATE</tt>=
=<tt>CREATE</tt>=
<syntaxhighlight lang='sql'>
<syntaxhighlight lang='sql'>
CREATE TABLE person
CREATE VIEW cust_view AS SELECT id, name, address FROM customer;  
( id smallint,  
  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]]
|-
|-
|}
|}


=<tt>ALTER</tt>=
=<tt>ALTER</tt>=
<syntaxhighlight lang='sql'>
ALTER TABLE person [...]
</syntaxhighlight>
==Add/Remove a Column==
<syntaxhighlight lang='sql'>
ALTER TABLE person ADD COLUMN birthday DATE;
</syntaxhighlight>
:{| class="wikitable" style="text-align: left;"
|-
| [[PostgreSQL_DDL_Operations#Add/Remove_a_Column|PostgreSQL]] || [[MySQL_DDL_Operations#Alter_Table|MySQL]]
|-
|}


=<tt>DROP</tt>=
=<tt>DROP</tt>=
<syntaxhighlight lang='sql'>
DROP TABLE person [...]
</syntaxhighlight>
:{| class="wikitable" style="text-align: left;"
|-
| [[PostgreSQL_DDL_Operations#Drop_a_Table|PostgreSQL]] || [[MySQL_DDL_Operations#Drop_Table|MySQL]]
|-
|}
=Features=
==<tt>AUTO_INCREMENT</tt>==
{{Internal|SQL_AUTO_INCREMENT#Overview|<tt>AUTO_INCREMENT</tt>}}

Latest revision as of 00:20, 25 May 2024

Internal

TODO

TO PROCESS: https://learning.oreilly.com/library/view/learning-sql-3rd/9781492057604/ch14.html

Overview

Virtual Table (View)

CREATE

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

ALTER

DROP