Table creation/Postal addresses: Difference between revisions

From Rosetta Code
Content added Content deleted
m (Alphabetized list)
No edit summary
Line 4: Line 4:


==[[MySQL]]==
==[[MySQL]]==
[[Category:MySQL]]


CREATE TABLE `Address` (
CREATE TABLE `Address` (
Line 15: Line 16:


==[[PostgreSQL]]==
==[[PostgreSQL]]==
[[Category:PostgreSQL]]


CREATE SEQUENCE address_seq start 100;
CREATE SEQUENCE address_seq start 100;
Line 26: Line 28:


==[[SAS]]==
==[[SAS]]==
[[Category:SAS]]


DATA address;
DATA address;
Line 33: Line 36:


==[[UDB DB2]]==
==[[UDB DB2]]==
[[Category:UDB DB2]]


CREATE TABLE Address (
CREATE TABLE Address (

Revision as of 02:26, 24 January 2007

Task
Table creation/Postal addresses
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 store addresses.

MySQL

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`)
);

PostgreSQL

CREATE SEQUENCE address_seq start 100;
CREATE TABLE address (
  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
);

SAS

DATA address;
  LENGTH addrID 8. street 50$ city 25$ state 2$ zip 20$;
  STOP;
RUN;

UDB DB2

CREATE TABLE Address (
	addrID		Integer		generated by default as identity,
	addrStreet	Varchar(50)	not null,
	addrCity	Varchar(25)	not null,
	addrState	Char(2)		not null,
	addrZIP		Char(10)	not null
)