Table creation: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1:
{{task}}
 
In this task, the goal is to create a table to storeexemplify addressesmost commonly used data types and options.
 
==[[UDB DB2PostgreSQL]]==
 
-- This is a comment
CREATE TABLE Address (
)
addrID Integer generated by default as identity,
CREATE SEQUENCE address_seqaccount_seq start 100;
addrStreet Varchar(50) not null,
CREATE TABLE Addressaccount (
addrCity Varchar(25) not null,
addrID account_id int4 PRIMARY KEY DEFAULT nextval('address_seqaccount_seq'),
addrState Char(2) not null,
addrZIP Char(10) created date not null default now(),
active bool not null default 't',
)
city username varchar(2516) unique not null,
 
age int2,
==[[MySQL]]==
notes text
 
CREATE TABLE `Address` (
`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`)
);
 
CREATE TABLE `Address`account_note (
==[[PostgreSQL]]==
account_id int4 not null REFERENCES account,
 
created timestamp not null default now(),
CREATE SEQUENCE address_seq start 100;
statenote varchar(2) text not null,
CREATE TABLE address (
unique(account_id, note)
addrID int4 PRIMARY KEY DEFAULT nextval('address_seq'),
street varchar(50) not null,
city varchar(25) not null,
state varchar(2) not null,
zip varchar(20) not null
);
Anonymous user