Table creation: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
In this task, the goal is to create a table to |
In this task, the goal is to create a table to exemplify most commonly used data types and options. |
||
==[[ |
==[[PostgreSQL]]== |
||
-- This is a comment |
|||
⚫ | |||
⚫ | |||
addrID Integer generated by default as identity, |
|||
⚫ | |||
addrStreet Varchar(50) not null, |
|||
⚫ | |||
addrCity Varchar(25) not null, |
|||
⚫ | |||
addrState Char(2) not null, |
|||
created date not null default now(), |
|||
active bool not null default 't', |
|||
⚫ | |||
⚫ | |||
age int2, |
|||
==[[MySQL]]== |
|||
notes text |
|||
⚫ | |||
`addrID` int(11) NOT NULL auto_increment, |
|||
`addrStreet` varchar(50) NOT NULL default '', |
|||
`addrCity` varchar(25) NOT NULL default '', |
|||
`addrState` char(2) NOT NULL default '', |
|||
`addrZIP` char(10) NOT NULL default '', |
|||
PRIMARY KEY (`addrID`) |
|||
); |
); |
||
⚫ | |||
==[[PostgreSQL]]== |
|||
account_id int4 not null REFERENCES account, |
|||
created timestamp not null default now(), |
|||
⚫ | |||
⚫ | |||
CREATE TABLE address ( |
|||
unique(account_id, note) |
|||
⚫ | |||
street varchar(50) not null, |
|||
⚫ | |||
⚫ | |||
zip varchar(20) not null |
|||
); |
); |