Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPerに知ってほしいRDBの事 その3

PHPerに知ってほしいRDBの事 その3

PHPカンファレンス関西 2016の資料です。
http://conference.kphpug.jp/2016/

soudai sone

July 09, 2016
Tweet

More Decks by soudai sone

Other Decks in Technology

Transcript

  1. ࣮ߦܭը CREATE TABLE `demo`.`users` ( `id` INT NOT NULL AUTO_INCREMENT

    COMMENT '', `name` VARCHAR(45) NOT NULL COMMENT '', `age` INT NOT NULL COMMENT '', `created` DATETIME NOT NULL DEFAULT NOW () COMMENT '', PRIMARY KEY (`id`) COMMENT '' ); ——શ݅Λબ୒͢ΔͷͰςʔϒϧεΩϟϯ SELECT * FROM demo.users; ——PRIMARY KEYʢINDEXʣΛར༻ͨ͠ྫ SELECT * FROM demo.users WHERE id > 100; ——INDEX͕ແ͍ͷͰςʔϒϧεΩϟϯ SELECT * FROM demo.users WHERE age > 20;
  2. JOIN SELECT * FROM users INNER JOIN users AS tmp

    ON tmp.id = users.id AND tmp.id BETWEEN 10 AND 100000 WHERE users.created = '2016-02-27 04:31:32'
  3. ෳ਺ར༻ͨ͠INDEX CREATE TABLE public.users ( id integer NOT NULL DEFAULT

    nextval('users_id_seq'::regclass), name text NOT NULL, age integer NOT NULL, created timestamp without time zone NOT NULL DEFAULT now(), CONSTRAINT users_pkey PRIMARY KEY (id)); CREATE INDEX users_created_idx ON public.users USING tree (created); ——idͱcreatedͷINDEXΛར༻͢Δ SELECT * FROM users WHERE id < 100 AND created < '2016-02-27 05:41:28';
  4. ૬ؔαϒΫΤϦ SELECT * FROM users WHERE age IN (SELECT age

    FROM users WHERE id BETWEEN 10 AND 100000)
  5. JE ໊લ ճ౴  TPOF IPHF  40/& GVHB 

    TPVEBJ GPP  UBLFUPNP CBS
  6. JE OBNF  TPOF  40/&  TPVEBJ  UBLFUPNP

    JE ࣭໰  ࣭໰̍  ࣭໰̎  ࣭໰̏  ࣭໰̐ ճ౴ऀ@JE ࣭໰@JE ճ౴ ճ౴೔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