Table creation: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1:
{{task}}
In this task, the goal is to create a table to
==[[
-- This is a comment
CREATE TABLE Address (▼
active bool not null default 't',
▲ )
age int2,
notes text
CREATE TABLE `Address` (▼
);
account_id int4 not null REFERENCES account,
created timestamp not null default now(),
▲ CREATE SEQUENCE address_seq start 100;
unique(account_id, note)
▲ addrID int4 PRIMARY KEY DEFAULT nextval('address_seq'),
▲ city varchar(25) not null,
▲ state varchar(2) not null,
);
|
Revision as of 14:55, 23 January 2007
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
In this task, the goal is to create a table to exemplify most commonly used data types and options.
PostgreSQL
-- This is a comment CREATE SEQUENCE account_seq start 100; CREATE TABLE account ( account_id int4 PRIMARY KEY DEFAULT nextval('account_seq'), created date not null default now(), active bool not null default 't', username varchar(16) unique not null, age int2, notes text ); CREATE TABLE account_note ( account_id int4 not null REFERENCES account, created timestamp not null default now(), note text not null, unique(account_id, note) );