09/21/2020
SQL
DATE
we gotta set up the 날짜 Format (**but note, for best practice you gotta use the 단일행함수 (single row function) that converts a data into DATE form).
> ALTER SESSION SET nls_date_format = 'YY/MM/DD';
But in general, the DATE type is in this form:
YYYY/MM/DD:HH24:MI:SS
--> the default for 시/분/초 is 00:00:00
> ALTER SESSION SET nls_date_format = 'YYYY/MM/DD';
요즘엔 YEAR를 꼭 4자리 씀. 1920년에 태어나 아직 살아있는 사람들도 많으니까.
실제론 RDB (Relational DataBase) 에선 data 못 지움. 지웠다고 할땐 그냥 식별할수 없게 만드는 거임.
sometimes, to avoid NULL, people use -1 instead.
type NUMBER means it's likely to be involved in a math operation, while VARCHAR means it's not.
Null 은 비교연산자도 안 통함. 그래서 IS NULL & IS NOT NULL function을 써야함. 그치만 첨부터 NULL이 있었다는 거는 이 database에 심각한 문제가 있다는 거임.
관계연산자와 LIKE 연산자
LIKE 연산자 (also known as 패턴 연산자)
> SELECT ... FROM ... WHERE 컬럼 LIKE '비교 문자열' ... ORDER BY ... ;
(side note: 원래 이름은 성과 이름으로 나눠 넣어져야 함. 더 좋게는 3개까지 컬럼이 있어야함. First/Middle/Last Name.)
**If SQL doesn't return anything after a query, that means the query wasn't executed.
**Be careful not to confuse 'LIKE' with '='! '=' only returns something if it's identical to the phrase that comes after it.
DATE
(side note: Windows의 기초적인 에디터는 Note Pad. if you type in SQL> ed, it opens up Note Pad with the query that was typed in last in the cmd prompt. Linux의 기초적인 에디터는 Vi 임.)
SQL에서 sqlplus는 브라우저 와 같은 개념임. SELECT query를 type하면, sqlplus가 그거를 Server Processor (SP) 한테 보냄. 그럼 SP가 Oracle에서 검색을 하고 그렇게 찾은 data를 다시 sqlplus 에게 보냄. 그러면 sqlplus는 그걸 loop을 통해서 우리가 볼수 있는 형태로 cmd prompt에 띠움.
PHP
반복문 (while, for)
--> 보통 for loop 을 제일 많이 씀. everything written in while loop can be written in for loop, and vice versa. and for loop has higher readability, so everyone uses for loop whenever they can rather than while loops
초기식 - initializer (ex: $a = 1;)
증감식 - increment operator (ex; $a++;)
4 main components of any loops:
Because the increment operator comes at the end of the while loop, you can't figure out how long the while loop is going to go until unless you read the whole while loop block. That's one reason why for-loops have higher readability.
To do a client-side validation of sorts for the form:
<script>
window.alert('2에서 9사이에 값을 입력하세요!'); //알림창을 띠움
history.go(-1); //goes back to the previous page on browser
</script>
--> 이걸 echo() 로 php code 안에다가 적음.
exit; --> you do this after that script because this will clear the memory and stuff like that right away so that's good in general rather than not doing it and waiting for the system to clean it up some time later.
(side note: PHP의 주석은 // 로 하면 됨!)