çªç¶ã§ããçæ§ã¯ã稼åæ¸ã¿ãµã¼ãã¹ã®DBãããã¼ãã«ã«ã©ã ãåé¤ãããããããã¨ãããã¾ãã§ããããï¼ãåºæ¬çã«åé¤ã¯ã¾ããããªãã®ã§ã¯ã¨æãã¾ãããã£ãããªãã®ï¼ãã¨æãããæ¹ãããã£ãããããããã¾ãããããã£ã¨ãã®è¨äºãèªãã°ãªãå¤ãã®æ¹ãã«ã©ã åé¤ãé¿ããã®ãããããã¨ã§ãããã
ã¨ã¯ããããããã¦ä½¿ããªãã«ã©ã ããã¼ãã«ã«æºã¾ã£ã¦ããã¨ããã¦æ°è¦å å ¥ã¡ã³ãã¼ãã³ã¼ãã«ãã£ããã¢ãããã妨ãã¨ãªãã¬ãã«ã«ã¾ã§æºã¾ã£ã¦ããããã¾ãããã¤ãã¯å¤§æé¤ã®ã¨ããããããã§ããDBã¯å¯¿å½é·ãã§ãããããããããã¨ãã«å®éã©ã®ãããªæé ã§ã«ã©ã ãåé¤ããã®ãè¦ã¦ããã¾ããããã¨ã ã¹ãªã¼ã¨ã³ã¸ãã¢ãªã³ã°ã°ã«ã¼ãUnit1ï¼è£½è¬ããã¢ã¼ã·ã§ã³ï¼ã»Unit9ï¼æ²»é¨è¨åºç 究æ¯æ´ï¼ãã¼ã ã¨ã³ã¸ãã¢ã®ä¸æµ¦ [è¨äºä¸è¦§ ï]ããæè¿å®éã«ãã£ãä½æ¥ããç¥è¦ããå±ããã¾ãã
- é·ãã®ã§3è¡ã§
- èãæ¹
- 1. ãã®ã«ã©ã ã¸ã®ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ããªãã
- 2. ã«ã©ã ãNULL許容ã«ãã
- 3. ã¢ããªã±ã¼ã·ã§ã³å´ã§ãã®ã«ã©ã ã¸ã®ã¢ã¯ã»ã¹ããªããããªãªã¼ã¹
- 4. ã«ã©ã ãDROP
- ä»ã®ã±ã¼ã¹ï¼ä¸è¦ãªãã¼ãã«ã®åé¤
- ä»ã®ã±ã¼ã¹ï¼ã«ã©ã ã®æ¹å
- ã¾ã¨ã
- We are hiring
é·ãã®ã§3è¡ã§
- ãã®ã«ã©ã ã¸ã®ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ããªãã
- ã«ã©ã ãNULL許容ã«ãã
- ã¢ããªã±ã¼ã·ã§ã³å´ã§ãã®ã«ã©ã ã¸ã®ã¢ã¯ã»ã¹ããªããããªãªã¼ã¹
- ã«ã©ã ãDROP
ãã¿ã¾ãã4è¡ã«ãªã£ã¦ãã¾ãã¾ãããã§ããã以ä¸ã¯æ¸ããã¾ããã
èãæ¹
æã大äºãªç¹ã¯ç¨¼åä¸ã®ãµã¼ãã¹ããªãªã¼ã¹åå¾ã§ç¡ç¨ã«ã¨ã©ã¼ãèµ·ãããªãããã«ã¨ãããã¨ã«ãªãã®ã§ãããããã«å ãã¦ãéçºã»QAç°å¢ã®ãã¨ã§ãããå¥ã«ãã£ã¼ãã£ã¼ãã©ã³ããåã£ã¦éçºãQAã®ä½æ¥ããã¦ãã人ã ãè©°ã¾ãªããã¨ãéè¦ãªè¦³ç¹ã¨ãªãã¾ããããã¦å¿ãã¦ã¯ãããªãããã¼ã¿åæããã¦ãã人ã ã¸ã®ç®é ããä¸ã¤ç®ã§ããã
ãã¦ã¾ããã«ã©ã åé¤ãã¢ããªã±ã¼ã·ã§ã³ã¨DBã©ã¡ãããå ã«ãããã¨ããè°è«ãã§ãã¾ãã両è ãå³å¯ã«ãåæãã«ãªãªã¼ã¹ã¯ã§ãã¾ããããããã©ã¡ããå ã«ãã¾ããããããå ã«DBããã«ã©ã ãåé¤ããã¨ãã¢ããªã±ã¼ã·ã§ã³ãã¨ã©ã¼ãåºãå§ããã®ã¯å®¹æã«æ³åãã¤ãã¾ããã§ã¯ãã¢ããªã±ã¼ã·ã§ã³ãå ãã
å ã«ã¢ããªã±ã¼ã·ã§ã³å´ãããã®ã«ã©ã ã¸ã®åç §ããªããã¦ãªãªã¼ã¹ããã°ãã¨ã¯è½ã¡çãã¦DBããã«ã©ã ãåé¤ã§ãããã¯ãããã®çºæ³ã§ã»ã¼ééãããã¾ããããã ãããã ãã®é çªã§è¡ãã¨ã¢ããªã±ã¼ã·ã§ã³å´ãªãªã¼ã¹ã¨åæã«å¤§éã®ã¢ã©ã¼ããé£ã³å§ããå¯è½æ§ãããã¾ããä½ããããªãã£ãã§ãããã
ãï¸
INSERTæãè½ã¡ãããã«ãªã£ãã®ã§ããã¢ããªã±ã¼ã·ã§ã³å´ã§ã«ã©ã ãã¾ã£ããåç §ããªããªãã°ãINSERTããã®ã«å¿ è¦ãªã«ã©ã ãã¼ã¿ã足ããè»ä¸¦ã¿ã¨ã©ã¼ã¨ãããããã¤ã¾ãã¢ããªã±ã¼ã·ã§ã³å´ããã«ã©ã åç §ãåé¤ããã®ã«å ç«ã£ã¦ãããããªãã§ãINSERTãéããããã«ãã¦ãããªãã¦ã¯ãªããªãã£ãã®ã§ãã
ãã®ãINSERTæãéãããã«âã¢ããªã±ã¼ã·ã§ã³å´ããåé¤âDBããåé¤ã®3段éããµã¼ãã¹æ¬ä½ã§ã®ä¿®æ£ã¨ããã¨ãããã«ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ã¸ã®èæ ®ãå ¥ãã¦åè¿°ã®4段éã¨ãªãã¾ãã
1. ãã®ã«ã©ã ã¸ã®ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ããªãã
äºæ¥ã¨ãã¦æä¾ãã¦ãããµã¼ãã¹ãªãã°ãå¤ããå°ãªãããã®å©ç¨å®ç¸¾ã»å®æ ããã¼ã¿åæãããéè¨ããããããã¼ãºãããã¯ãã§ããããªãã¡ãã¢ããªã±ã¼ã·ã§ã³DBãåæç¨DBã«åãè¾¼ãã§å å·¥ãã¦ãããã¼ã ãããã¯ãã§ããã¢ããªã±ã¼ã·ã§ã³æ¬ä½ã®éçºã«éä¸ãã¦ããã¨ã¤ããããããã¼ã ã¸ã®ç®é ããå¿ãã¦ãã¾ããæ°æ©è½ãªãªã¼ã¹ã¨åæã«ãã¼ã¿åæãã¼ã æ¹é¢ããæ²é³´ãä¸ãã£ã¦ãã¾ã£ããªãã¦çµé¨ããæã¡ã®æ¹ãå°ãªããªãã®ã§ã¯ã
ã§ãããå®ç³ã¨ãã¦ãã¤ãã¹ããããè¸ãããã«ãã¾ããããDBã¹ãã¼ãå¤æ´ã®æåã®ä¸æã¯ãã¼ã¿åæãã¼ã ç¸è«ãç¹ã«ä½ããåé¤ãããããªç¢ºå®ã«ã¨ã©ã¼ãèµ·ããå¤æ´ãªãã°çµ¶å¯¾ã«ã¯ãããªãäºé ã¨ãªãã¾ãã
ãã¼ã¿åæãã¼ã ããã®ä¸æµã§ã®å½±é¿ãããã«èªã¿åããã¨ã¯éããããã¼ã¿ãã¼ããããç¡éªæ°ã«ãã®ã«ã©ã ãæ¶ãã¦ãã¾ããã¨ã¯éãã¾ãããã¾ãã¯ä¿å®çã«ã次ã®ããã«åãè¾¼ã¿SQLã§ç¡æå³ãã¼ã¿ãåãè¾¼ãããã«å¤æ´ãªã©ãããã¨ã«ãªãã§ãããã
SELECT id, tenant_id, name, - billing_start_date, + DATE'1970-01-01' AS billing_start_date, - billing_end_date + DATE'2200-12-31' AS billing_end_date FROM users
NULLé許容ã ã£ãbilling_start_date, billing_end_dateãåé¤ããã¨ããã¹ãã¼ãªã¼ã§ãããä¸æµå½±é¿ãé²ãããNULLã§ã¯ãªãåºå®å¤ãèªã¿è¾¼ãããã«ããå¤æ´ããã¦ããä¾ã§ã*1ã
2. ã«ã©ã ãNULL許容ã«ãã
ãã®ã«ã©ã ãæå®ããªãã¦ãINSERTæãéãããã«ããã¨ãããã¨ã§ããã¨ãããã¨ã¯NULL許容ã«ããã®ã§ãªãDEFAULTãè¨å®ããã¨ããã®ãå¥è§£ã«ãªãã¾ãããã ããããæ¶ãã«ã©ã ã«å¤ãæãããå¿ è¦ãããããã¾ãããããNULL許容ã«ãã¦ããã®ã§ååã§ããããæ¬æ¥NULLé許容ã§ãã¼ã¿ãã¼ãã«ãå¿ ãå¤ãåãè¾¼ã¾ãã¦ããã®ã ã¨ãã¦ãã1.ã®æ®µéã§ã¡ããã¨ããã¼å¤ãåã£ã¦ãããããã«ãªãã¾ããããå¿ç½®ããªãNULL許容ã«ã§ãã¾ããã
ã«ã©ã ããã¨ãã¨NULL許容ã ã£ãããã®ã¹ãããã¯ãã¹ã§ããããã§ã¨ããããã¾ãã
3. ã¢ããªã±ã¼ã·ã§ã³å´ã§ãã®ã«ã©ã ã¸ã®ã¢ã¯ã»ã¹ããªããããªãªã¼ã¹
ã¢ããªã±ã¼ã·ã§ã³ããå ã«ã«ã©ã åç §ããªããã¾ãããã¨ããã®ã¯ç·è«ã§ã話ãã¾ããããããã§ããã¦ããã«ããã£ãããªãªã¼ã¹ãã¦ãã¾ãã¾ããããã¨ããã®ãä»ãå ãã¾ããã¤ã¾ãåæ¥ã«DBããã®ã«ã©ã åé¤ã¾ã§ãã£ã¦ãã¾ããã«å¥ã®æ©ä¼ã«ãã¾ãããã¨ãããã¨ã¨ããã®çç±ããä»ã®ã¡ã³ãã¼ã®éçºã»QAãæ¢ããªãããã«ã¨ãã観ç¹ã§ãã
ã¢ããªã±ã¼ã·ã§ã³ãããDBãããã«ã©ã ãåé¤ããã¨ããä¿®æ£ãããããªãªã¼ã¹ããåã«QAããã«ã¯ãQAç°å¢ã§DBããã«ã©ã åé¤ãããã¨ã«ãªãã¾ããããããã¨ãä»ã®ãã£ã¼ãã£ã¼ãã©ã³ããQAç°å¢ã§ã¨ã©ã¼ãåºãã¦ãã¾ãããã«ãªãã¾ãããããé²ããã¨ããã¨ã©ã®ãããªæé ãè¸ã¾ãªãã¨ãããªããã¨ããã¨
- ã¢ããªã±ã¼ã·ã§ã³ããã«ã©ã åç
§ãåé¤ããä¿®æ£ãæ¸ãâQAâãªãªã¼ã¹
ï¼ãã®éãDBã¹ãã¼ãã«å¤æ´ã¯å ãããªãã®ã§ä»ã®ãã£ã¼ãã£ã¼ãã©ã³ããåé¡ãªãåãï¼ - åãã£ã¼ãã£ã¼ãã©ã³ãã§æ¬æµã®ææ°ããã¼ã¸ãªããªãã¼ã¹ãªããã¦ããã
ï¼åãã©ã³ãã¨ããDBããã«ã©ã ããã¤æ¶ãã¦ãåãç¶æ ã«ãªã£ãï¼ï¼ - DBããã«ã©ã ãåé¤ãããã¤ã°ã¬ã¼ã·ã§ã³ãQAâãªãªã¼ã¹
ï¼QAãã段éã§ã¾ãQAç¨DBããã«ã©ã ãæ¶ããããåãã£ã¼ãã£ã¼ãã©ã³ãã¯åé¡ãªãï¼
äºäººä»¥ä¸ã®ã¨ã³ã¸ãã¢ããããªããã¢ããªã±ã¼ã·ã§ã³ããã¨DBããã«ã©ã ãåé¤ããã®ã¯å¥ã®ãªãªã¼ã¹æ©ä¼ã«åããã»ããããã¨ãªãã¾ããæåã«æ¸ãã4æé ã®ãã¡ãã®3çªç®ã§ãææ«ã®ããªãªã¼ã¹ãã¨ããã®ã«ã¯ãã¼ã ã®çã«æ¬æµãã¼ã¸ããã¦ãããã¨ããã¹ããããå«ã¾ãã¦ãããã¨ã«ãªãã¾ããã
4. ã«ã©ã ãDROP
ãã¯ãããªããé»ããã®ã¯ããã¾ãããä½å¹´ãããã¦æºã¾ã£ããããªãã«ã©ã ããã£ããåé¤ãã¾ãããã
ALTER TABLE users DROP COLUMN billing_start_date; ALTER TABLE users DROP COLUMN billing_end_date;
ãã¤ãããã¾ã§ããã
ä»ã®ã±ã¼ã¹ï¼ä¸è¦ãªãã¼ãã«ã®åé¤
ãã¼ãã«åé¤ã®å ´åã«ã¯ãINSERTæãéããªããªãåé¡ãããã¾ããããã£ã¦å°ãæé ã¯ç°¡åãä»åº¦ã¯æ¬å½ã«3è¡ã§æ¸ãã¾ãã
- ãã®ã«ã©ã ã¸ã®ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ããªãã
- ã¢ããªã±ã¼ã·ã§ã³å´ã§ãã®ãã¼ãã«ã¸ã®ã¢ã¯ã»ã¹ããªããããªãªã¼ã¹
- ãã¼ãã«ãDROP
ä»ã®ã±ã¼ã¹ï¼ã«ã©ã ã®æ¹å
ååãå®æ ã表ããªããªã£ã¦ãã¾ã£ãã®ã§æ¹åãããã¨ãããã¼ãºããã¾ã«çããã®ã¯ãã®éãã§ãããããâ¯â¯æ¹åã¯é£ããã§ãï¼ãããã©ããã¦ãããããã¨ãã¦ããæ°ããã«ã©ã ãä½ã£ã¦ä½¿ãããã«ãã¦å¤ãã«ã©ã ã¯ä½¿ãã®ããããï¼ããã¦ãã¤ã大æé¤ã®ã¨ãã«â¯â¯ï¼ã¨ãããããªãã§ãããããã¡ããããã ã£ã¦ç°¡åã§ã¯ãªãã
- æ°ããã«ã©ã ãNULL許容ã§ä½ã
- ã¢ããªã±ã¼ã·ã§ã³ã®æ´æ°ç³»ã§ä¸¡æ¹ã®ã«ã©ã ã«æ¸ãè¾¼ãããã«ãããªãªã¼ã¹ï¼ä¸ã®ä¾ã¨åããããªãªã¼ã¹ã¨ã¯åãã£ã¼ãã£ã¼ãã©ã³ãã«ãåãè¾¼ããã¨ã¾ã§ãæå³ãã¾ãï¼
- å¤ãã«ã©ã ããæ°ããã«ã©ã ã¸ãã¼ã¿ãã³ãã¼ããDMLãDBã§æµã
- ãã®æç¹ã§ãNULLé許容ã«ããå¿ è¦æ§ãããã°ããã§ãã
- ã¢ããªã±ã¼ã·ã§ã³å¤ããã®ã¢ã¯ã»ã¹ãæ°ããã«ã©ã ã¸å¤æ´
- ã¢ããªã±ã¼ã·ã§ã³ã®åç §ç³»ãæ°ããã«ã©ã ã¸å¤æ´ãããªãªã¼ã¹
- ã¢ããªã±ã¼ã·ã§ã³ã®æ´æ°ç³»ã§å¤ãã«ã©ã ã¸ã®æ¸ãè¾¼ã¿ã¯ãããï¼NULLé許容ãªãç¡æå³ãã¼ã¿ãæ¸ãè¾¼ãããã«ããï¼
ããããªä¸å¤§ä½æ¥ã¨ãªãã¾ããã¢ããªã±ã¼ã·ã§ã³ããã°ã©ã å ã§å¤æ°åããã£ã¼ã«ãåãå¤ãããªãã¡ã¯ã¿ãªã³ã°ã¨ã¯æ¡éãã®å¤§å¤ãã§ãã
ã¾ã¨ã
ãã¾ããå«ãã¦ãã®ãããªãããã¨ãªã¹ããã覧ã«å ¥ããã®ã§ãããã¹ãã¼ãå¤æ´ã«ã¯éããªããã¿ã¼ã³ãããã¾ãããä¸è¨äºã§ã¯æ¬æ¥ã¨ã¦ãç¶²ç¾ ã§ãããã®ã§ã¯ããã¾ãããããã§ãã®ã¨ãã©ãã§ããããå®æ½ãã©ã³ãç«ã¦ããããããããã¾ã§ã§ãã©ã³ãç«ã¦ãã®ã«èãã¦ãããã¨ã¯ä½ã ã£ãã®ããæ¯ãè¿ã£ã¦ã¿ã¾ãããã
æ¥ã«äººéèã話ã«ãªã£ã¦ãã¾ãã¾ãããä»è ã¸ã®ç®é ããåºçºç¹ã¨ãªã£ã¦ããã¨æãã¾ãããã¼ã¿åæãã¼ã ããä»ã«éçºã»QAãã¦ãã人ããã¾ãåç §ç³»ã¯æ´æ°ç³»ããæ´æ°ç³»ã¯åç §ç³»ãã¨ãã£ãããã«ä»ã®äººéãä»ã®ã¦ã¼ã¹ã±ã¼ã¹ãã¡ãè©°ã¾ãªãããåã¹ãããã§èãããã¨ã§æ²é³´ã®ä¸ãããªãã¹ãã¼ãå¤æ´ãæ§æãããã¨ãã¦ããã®ã§ãã
ãã¡ããã人éã®æ³ååã«ã¯éããããã¾ããããæ³åã§ããªãã£ãã¨ããã¾ã§ã¯ç®ãé ãã¾ããããããã¦æ²é³´ãä¸ãããã¨ã«ãªã£ã¦ãã¾ã£ããæ¯ãè¿ãããã¦ãããããã°ãã£ã¨åºãç®ãé ããããã«ãªãã¾ãã次ã®ã¹ãã¼ãå¤æ´ã¯ãã£ã¨ãã£ã¨ãã¾ãããã¾ãã
We are hiring
å½±é¿ç¯å²ã«ç®ãé ã£ã¦ãããã§ãæ²é³´ãä¸ãããã¦ãã¾ã£ããæ¯ãè¿ã£ã¦ãã£ã¨ç®ãåºãé ããããã«ããâ¯â¯ãã®ãµã¤ã¯ã«ã¯ã¹ãã¼ãå¤æ´ä½æ¥ã«éããªããã¨ããã¹ã¦ã®éçºåéã§ã¨ã³ã¸ãã¢ãæé·ããã¦ããããã¨ã§ããç§éã¨ã ã¹ãªã¼ã®ã¨ã³ã¸ãã¢ã¯ãã¹ããã¨ãèªåã¨ãã¼ã ã§èãã¦éçºãã¦ãã¾ãã®ã§ãããã ãå½±é¿ç¯å²ãèãããããã¨ãã«ã¯å½±é¿ãèªã¿è½ã¨ãã¦ãã¾ã£ãããæ¥ã ãã¦ãã¾ããããããæé·ãµã¤ã¯ã«ã®åã£ã¦ããç°å¢ããèå³ãã£ãããã¡ãã®ãã¼ã¸ããã©ãããå¿åãåæã«ããªãã«ã¸ã¥ã¢ã«é¢è«ããã£ã¦ãã¾ãã
*1:é ãæªæ¥ã¨ããæå³ã§2200å¹´ã¨ããããããè¿ãå¹´æãæ¡ç¨ãã¦ããã®ãæ°ã«ãªãæ¹ãããã£ãããããããã¾ãããããããã¼ã¿åæåéã ã¨ãã使ãããPythonã©ã¤ãã©ãªã®pandasãæ¥ä»ã¨ãã¦æ大2262-04-11ã¾ã§ããæ±ããªãã¨ããåé¡ããããããã«å¼ã£ããããªãåãã®è¯ããå¹´å·ã¨ããã¨ãã®ãããã«ãªããªã©ã¨ãã£ãäºæ ãããã¾ãã175å¹´å¾ã§ããã175å¹´åã¯ã¾ã æ±æ¸æ代ã§ãããããã§ãç¸å½é ãæªæ¥ã§ããã