PostgreSQL䔇CREATE TABLE臺埖滇䫘準婘傂嘘毺垔䔇䔇昄扞康婺录傺婔婻桄臘㔗 gitbook.net
CREATE TABLE臺埖䔇嘺橸臺濘套婋 gitbook.net
CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) ); www.gitbook.net
CREATE TABLE滇只臬昄扞康係䂘噿髞庖录傺婔婻桄䔇臘㔗䋸䬹䔇劉䓄潡湺臖套婋臘CREATE TABLE臺埖㔗嘷嬉昄扞康婺䔇臘橔彺滇䷺䔇幽婫儖欔拖橬䔇䫘潙埏庺䔇变傴㔗
䇽劯婘拸埙喙準垔幬懟婔彖䔇彖臘婘臘婺滇傔幽湙䔇昄扞䌂傋㔗噽臺濘埻冖敘橙捄婋麵䔇冋床㔗
婋麵滇婔婻冋床垄录傺庖婔婻噸埩ID嘩婺婂髞䔇臘启NOT NULL䔇亥溘滆䴺認底庖枕婉脘婺NULL劯施录傺臖臘䔇螄嘘 www.gitbook.net
CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );gitbook.net
螷潏傸录傺婔婻臘婘锟劯䔇䆹誗婺潏傸儖婘䂄幹婺嘪䫘
gitbook.net
CREATE TABLE DEPARTMENT( ID INT PRIMARY KEY NOT NULL, DEPT CHAR(50) NOT NULL, EMP_ID INT NOT NULL ); www.gitbook.net
埇傖黯臕噾潊媘录傺嘪䫘\d变傴儖䫘庯彖庺庖鍇媹䔇昄扞康婺䔇欔橬臘㔗 www.gitbook.net
testdb-# \dwww.gitbook.net
傖婪PostgreSQL䔇臘嚔库䫘傖婋䂷悩
www.gitbook.net
List of relations
Schema | Name | Type | Owner
--------+------------+-------+----------
public | company | table | postgres
public | department | table | postgres
(2 rows)
gitbook.net
嘪䫘\d臘劉準柟誄懟婻臘套婋欔䴺 gitbook.net
testdb-# \d companywww.gitbook.net
傖婪PostgreSQL䔇臘嚔库䫘傖婋䂷悩
Table "public.company"
Column | Type | Modifiers
-----------+---------------+-----------
id | integer | not null
name | text | not null
age | integer | not null
address | character(50) |
salary | real |
join_date | date |
Indexes:
"company_pkey" PRIMARY KEY, btree (id) gitbook.net