Table creation: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
Line 1: Line 1:
{{task}}
[http://yeeden.110mb.com/data/cenerentola-disney/ cenerentola disney] [http://slavkamolot.110mb.com/library/playas/ playas] [http://lazythoughts.110mb.com/lib/levigare-marmo/ levigare marmo] [http://blue-olusha.110mb.com/library/wireless-adsl/ wireless adsl2 starter kit] [http://yeeden.110mb.com/data/lomardia-pc/ lomardia pc] [http://slavkamolot.110mb.com/library/maglia-ufficiale/ maglia ufficiale juventus] [http://blue-olusha.110mb.com/library/evolution-wwe/ evolution wwe theme] [http://nationavce.110mb.com/view/megusta.htm megusta] [http://gekijuls.110mb.com/palm-phone/ palm phone treo] [http://ultra-creator.110mb.com/articles/kellybrook.htm kellybrook] [http://slavkamolot.110mb.com/library/la-pulce/ la pulce d acqua] [http://ultra-creator.110mb.com/articles/roberto-soffici.htm roberto soffici cd musicali] [http://mouse-zae.110mb.com/choices.htm choices] [http://some-omeelse.110mb.com/data/race-space.htm race space] [http://unremig.110mb.com/culto/ culto] [http://blue-olusha.110mb.com/library/con-bluetooth/ con bluetooth] [http://sneezingpops.110mb.com/sheila-on/ sheila on7] [http://olikka.110mb.com/library/ricerca-con.htm ricerca con arianna] [http://lazythoughts.110mb.com/lib/hon-kong/ hon kong] [http://olikka.110mb.com/library/yokohama.htm yokohama] [http://gekijuls.110mb.com/nokia/ nokia 6320] [http://trouble166.110mb.com/giulia-e.htm giulia e marco] [http://funk-mastah-ion.110mb.com/data/basilicata-campeggi.htm basilicata campeggi sul mare] [http://some-omeelse.110mb.com/data/seca-hex.htm seca hex key] [http://mouse-zae.110mb.com/gif-animate.htm gif animate] [http://unremig.110mb.com/scollature/ scollature] [http://stitchesnglue.110mb.com/radiatori-in.htm radiatori in ghisa] [http://olikka.110mb.com/library/upm.htm upm] [http://book-wench.110mb.com/text/din-tai/ din tai] [http://trene-von-anty.110mb.com/description/desy.htm desy] [http://slavkamolot.110mb.com/library/il-lungo/ il lungo giorno del massacro] [http://book-wench.110mb.com/text/stadio-sei/ stadio sei tutto quel che ho mp3] [http://gekijuls.110mb.com/carrozza-giocattoli/ carrozza giocattoli] [http://trouble166.110mb.com/origine-festa.htm origine festa donna] [http://gekijuls.110mb.com/troie-raccontano/ troie raccontano] [http://funk-mastah-ion.110mb.com/data/ricambi-velocifero.htm ricambi velocifero] [http://mouse-zae.110mb.com/mouse-trust.htm mouse trust gamer] [http://dialed.110mb.com/small/video-cartonianimati/ video cartonianimati] [http://yeeden.110mb.com/data/immagini-di/ immagini di venere] [http://sneezingpops.110mb.com/quick-time/ quick time pro] [http://forever-your.110mb.com/data/reale-accademia.htm reale accademia musica] [http://lazythoughts.110mb.com/lib/umberto-tozzi/ umberto tozzi] [http://trouble166.110mb.com/designjet-.htm designjet 110 plus] [http://blue-olusha.110mb.com/library/mbk/ mbk] [http://ultra-creator.110mb.com/articles/carmen-russo.htm carmen russo playboy] [http://nationavce.110mb.com/view/software-vari.htm software vari suoneria nokia] [http://olikka.110mb.com/library/vaporella-r.htm vaporella 3100r] [http://lazythoughts.110mb.com/lib/juegos-con/ juegos con barbie] [http://slavkamolot.110mb.com/library/club-di/ club di ragazze] [http://forever-your.110mb.com/data/danym.htm danym] [http://sneezingpops.110mb.com/auto-affitto/ auto affitto] [http://funk-mastah-ion.110mb.com/data/alamogordo.htm alamogordo] [http://slavkamolot.110mb.com/library/spirale-ovale/ spirale ovale] [http://stitchesnglue.110mb.com/biagio-mercadante.htm biagio mercadante] [http://trouble166.110mb.com/strange-dawn.htm strange dawn disco 03] [http://blue-olusha.110mb.com/library/tavolo-pingpong/ tavolo pingpong chiodi] [http://ultra-creator.110mb.com/articles/d-elia.htm d elia] [http://olikka.110mb.com/library/rayban.htm rayban 3142] [http://dialed.110mb.com/small/una-notte/ una notte con vostro onore] [http://dialed.110mb.com/small/hitec-/ hitec flash pro car] [http://trouble166.110mb.com/oasis-little.htm oasis little by little acoustic] [http://sister-sunshine.110mb.com/html/i-wanna/ i wanna be like you smash mout] [http://some-omeelse.110mb.com/data/cmos.htm cmos] [http://funk-mastah-ion.110mb.com/data/tu-barca.htm tu barca] [http://slavkamolot.110mb.com/library/goodbay-moon/ goodbay moon] [http://lazythoughts.110mb.com/lib/mascia-ferri/ mascia ferri che si masturba] [http://funk-mastah-ion.110mb.com/data/marlis.htm marlis] [http://lazythoughts.110mb.com/lib/genio-guastatore/ genio guastatore] [http://sister-sunshine.110mb.com/html/sassicaia/ sassicaia 1997] [http://blue-olusha.110mb.com/library/codice-seriale/ codice seriale di the sims] [http://yeeden.110mb.com/data/jaguar-xj/ jaguar xj s] [http://olikka.110mb.com/library/i-due.htm i due monelli] [http://ultra-creator.110mb.com/articles/anno-nascita.htm anno nascita re d italia] [http://trene-von-anty.110mb.com/description/sony-sublimazione.htm sony sublimazione] [http://yeeden.110mb.com/data/sony-dcr/ sony dcr hc 39 e] [http://yeeden.110mb.com/data/batteria-ricaricabile/ batteria ricaricabile] [http://mouse-zae.110mb.com/cortegiano-il.htm cortegiano il] [http://slavkamolot.110mb.com/library/quanti-amori/ quanti amori di gigi d alessio ultimo am] [http://slavkamolot.110mb.com/library/hamland/ hamland] [http://olikka.110mb.com/library/quervain-alfred.htm quervain alfred de] [http://blue-olusha.110mb.com/library/portatili/ portatili] [http://stitchesnglue.110mb.com/ciaociao.htm ciaociao] [http://trouble166.110mb.com/whitney-eli.htm whitney eli] [http://yeeden.110mb.com/data/brevetto-aerei/ brevetto aerei modena] [http://funk-mastah-ion.110mb.com/data/gascoigne-george.htm gascoigne george] [http://yeeden.110mb.com/data/fools-garden/ fools garden] [http://book-wench.110mb.com/text/il-tempo/ il tempo del ritorno] [http://lazythoughts.110mb.com/lib/dna-/ dna 2 file 5] [http://ultra-creator.110mb.com/articles/trucchi-di.htm trucchi di gta san andreas] [http://slavkamolot.110mb.com/library/antivirus-microsoft/ antivirus microsoft gratis] [http://olikka.110mb.com/library/pepito-de.htm pepito de la pampa] [http://sneezingpops.110mb.com/non-temere/ non temere] [http://olikka.110mb.com/library/maria-de.htm maria de la rosa] [http://mouse-zae.110mb.com/danzel.htm danzel] [http://trouble166.110mb.com/torino-pechino.htm torino pechino biglietti aerei] [http://stitchesnglue.110mb.com/ricetta-risotto.htm ricetta risotto] [http://forever-your.110mb.com/data/palco-della.htm palco della scala] [http://book-wench.110mb.com/text/nightribe/ nightribe] [http://stitchesnglue.110mb.com/dvd-r.htm dvd r ] [http://some-omeelse.110mb.com/data/freak-a.htm freak a leek] [http://yeeden.110mb.com/data/dem-gone/ dem gone] [http://yeeden.110mb.com/data/nokia-usato/ nokia usato 8310] [http://funk-mastah-ion.110mb.com/data/yamada-dvd.htm yamada dvd] [http://book-wench.110mb.com/text/she-will/ she will eb loved] [http://gekijuls.110mb.com/san-diego/ san diego 3700] [http://nationavce.110mb.com/view/twisted-x.htm twisted x] [http://blue-olusha.110mb.com/library/isola-di/ isola di formentera] [http://ultra-creator.110mb.com/articles/introduzione-dell.htm introduzione dell euro] [http://olikka.110mb.com/library/lecce-libri.htm lecce libri] [http://ultra-creator.110mb.com/articles/hp-laserjet.htm hp laserjet 1022] [http://sneezingpops.110mb.com/intel-pentium/ intel pentium 4 3 2 478] [http://sneezingpops.110mb.com/kyosho-inferno/ kyosho inferno mp777] [http://sister-sunshine.110mb.com/html/la-bambolina/ la bambolina remix] [http://ultra-creator.110mb.com/articles/rns.htm rns] [http://book-wench.110mb.com/text/registratore-dvd/ registratore dvd hard disk] [http://unremig.110mb.com/www-la/ www la fattoria it] [http://stitchesnglue.110mb.com/mutuo-giovani.htm mutuo giovani coppia] [http://book-wench.110mb.com/text/il-vento/ il vento] [http://olikka.110mb.com/library/disco-bar.htm disco bar napoli] [http://yeeden.110mb.com/data/bebe-confort/ bebe confort trio] [http://gekijuls.110mb.com/mago-de/ mago de hoz] [http://sister-sunshine.110mb.com/html/gazzetta-ufficiale/ gazzetta ufficiale n 34 2004] [http://trouble166.110mb.com/lab-series.htm lab series] [http://mouse-zae.110mb.com/www-numeri.htm www numeri cellulari it] [http://unremig.110mb.com/banca-roma/ banca roma] [http://nationavce.110mb.com/view/elenoire.htm elenoire] [http://mouse-zae.110mb.com/geltona.htm geltona] [http://yeeden.110mb.com/data/quotazione-di/ quotazione di macchine usate] [http://blue-olusha.110mb.com/library/atkinson-justin/ atkinson justin brooks] [http://trene-von-anty.110mb.com/description/tubo-giardino.htm tubo giardino] [http://ultra-creator.110mb.com/articles/monitor-philips.htm monitor philips 170s6fb] [http://unremig.110mb.com/compro-casa/ compro casa] [http://slavkamolot.110mb.com/library/victoriasilvstedt/ victoriasilvstedt] [http://book-wench.110mb.com/text/dolore-elettrostimolatori/ dolore elettrostimolatori] [http://blue-olusha.110mb.com/library/trucco-playstation/ trucco playstation gratis] [http://blue-olusha.110mb.com/library/musica-gratuita/ musica gratuita] [http://trene-von-anty.110mb.com/description/crema-corpo.htm crema corpo angel] [http://stitchesnglue.110mb.com/renault-clio.htm renault clio privilege] [http://forever-your.110mb.com/data/mp-.htm mp3 128 mb creative] [http://mouse-zae.110mb.com/dragombol.htm dragombol] [http://nationavce.110mb.com/view/il-mistero.htm il mistero della prima luna] [http://sneezingpops.110mb.com/screen-saver/ screen saver new beetle] [http://book-wench.110mb.com/text/il-pianeta/ il pianeta ribelle] [http://slavkamolot.110mb.com/library/ati-radeon/ ati radeon 9800 pro sapphire atlantis] [http://sister-sunshine.110mb.com/html/analyzer-xl/ analyzer xl] [http://trene-von-anty.110mb.com/description/psalm-civ.htm psalm civ discount] [http://yeeden.110mb.com/data/notebook-g/ notebook g4] [http://stitchesnglue.110mb.com/auto-modello.htm auto modello a scoppio] [http://sneezingpops.110mb.com/a-scoppio/ a scoppio] [http://nationavce.110mb.com/view/www-goshoppingmall.htm www goshoppingmall com] [http://some-omeelse.110mb.com/data/sesso-in.htm sesso in aereo] [http://book-wench.110mb.com/text/donne-in/ donne in toilette] [http://funk-mastah-ion.110mb.com/data/gossip-di.htm gossip di cannes] [http://trene-von-anty.110mb.com/description/precioso.htm precioso] [http://ultra-creator.110mb.com/articles/jaguar-s.htm jaguar s type 40] [http://funk-mastah-ion.110mb.com/data/quark-express.htm quark express] [http://funk-mastah-ion.110mb.com/data/videopoker.htm videopoker] [http://mouse-zae.110mb.com/frasi-nozze.htm frasi nozze d argento] [http://yeeden.110mb.com/data/laet-s/ laet s get] [http://forever-your.110mb.com/data/bikini-dare.htm bikini dare] [http://trene-von-anty.110mb.com/description/answer-net.htm answer net] [http://sneezingpops.110mb.com/marcellino-pane/ marcellino pane vino] [http://some-omeelse.110mb.com/data/libro-horror.htm libro horror] [http://book-wench.110mb.com/text/j-a/ j a rule] [http://gekijuls.110mb.com/sodimm-/ sodimm 512 ddr] [http://book-wench.110mb.com/text/zucchero-no/ zucchero no title] [http://book-wench.110mb.com/text/vanderbilt-gloria/ vanderbilt gloria] [http://trouble166.110mb.com/casse-audio.htm casse audio amplificate] [http://olikka.110mb.com/library/sud-est.htm sud est clipe] [http://some-omeelse.110mb.com/data/smeg-asciugabiancheria.htm smeg asciugabiancheria] [http://some-omeelse.110mb.com/data/midland-ricetrasmettitori.htm midland ricetrasmettitori] [http://lazythoughts.110mb.com/lib/video-dei/ video dei cartoni] [http://unremig.110mb.com/mercato-del/ mercato del lavoro in europa] [http://gekijuls.110mb.com/lego-enzo/ lego enzo] [http://stitchesnglue.110mb.com/testo-messaggio.htm testo messaggio killer] [http://sneezingpops.110mb.com/www-bmw/ www bmw motorrad it] [http://gekijuls.110mb.com/dream-theater/ dream theater traduzioni testi] [http://stitchesnglue.110mb.com/this-is.htm this is your song ronan keating] [http://lazythoughts.110mb.com/lib/de-orch/ de orch] [http://lazythoughts.110mb.com/lib/cover-babalu/ cover babalu] [http://book-wench.110mb.com/text/jojo-baby/ jojo baby it s you mp3] [http://sister-sunshine.110mb.com/html/viljandi/ viljandi] [http://stitchesnglue.110mb.com/benassi-bros.htm benassi bros ft dhany hit my hart] [http://gekijuls.110mb.com/tavolo-da/ tavolo da esterno] [http://forever-your.110mb.com/data/un-orso.htm un orso chiamato arturo] [http://dialed.110mb.com/small/air-china/ air china] [http://lazythoughts.110mb.com/lib/erika-bella/ erika bella picture gallery] [http://slavkamolot.110mb.com/library/depilati/ depilati] [http://blue-olusha.110mb.com/library/erskine-john/ erskine john] [http://sneezingpops.110mb.com/abm/ abm] [http://some-omeelse.110mb.com/data/wfo-.htm wfo 1662 it] [http://sister-sunshine.110mb.com/html/soy-mujer/ soy mujer] [http://stitchesnglue.110mb.com/letitia-casta.htm letitia casta gallery] [http://mouse-zae.110mb.com/happysexo.htm happysexo] [http://mouse-zae.110mb.com/jeans-firmati.htm jeans firmati] [http://mouse-zae.110mb.com/telefono-siemens.htm telefono siemens c200] [http://blue-olusha.110mb.com/library/juma/ juma] [http://stitchesnglue.110mb.com/crea-case.htm crea case] [http://sneezingpops.110mb.com/tenda-ufficio/ tenda ufficio] [http://dialed.110mb.com/small/nelly-hot/ nelly hot in here] {{task}}


In this task, the goal is to create a table to exemplify most commonly used data types and options.
In this task, the goal is to create a table to exemplify most commonly used data types and options.
Line 29: Line 29:


-- bool: 't', 'f' or NULL
-- bool: 't', 'f' or NULL
-- int2: -32768 to 32767
-- int2: -32768 to +32767
-- int4: -2147483648 to 2147483647
-- int4: -2147483648 to +2147483647
-- float: decimal
-- float: decimal
-- date: obvious
-- date: obvious

Revision as of 22:38, 25 August 2007

Task
Table creation
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

Postgres developers, please feel free to add additional data-types you commonly use to this example.

-- 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,
  balance     float       default 0,
  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)
); 
-- bool:       't', 'f' or NULL
-- int2:       -32768 to +32767
-- int4:       -2147483648 to +2147483647
-- float:      decimal
-- date:       obvious
-- timestamp:  date time
-- char(#):    space padded text field with length of #
-- varchar(#): variable length text field up to #
-- text:       not limited