09/29/2020
SQL
Setting up PKs and FKs
> CREATE TABLE 테이블 (
....
CONSTRAINT 제약조건이름 PRIMARY KEY (column),
CONSTRAINT 제약조건이름 FOREIGN KEY (column)
REFERENCES reference_table (reference_column)
);
OR
> CREATE TABLE 테이블 (
columnname date_type CONSTRAINT 제약조건이름 PRIMARY KEY,
column_name data_type CONSTRAINT 제약조건_이름 FOREIGN KEY
REFERENCES ref_table (ref_column),
....
);
제약 조건 (Constraint Conditions) 조회
--> 여기서 C 컬럼 밑에 P는 Primary Key, R은 Foreign Key를 뜻함
--> 두번째 example 처럼 p 와 c 로 user_constraints 별명을 나눠쓰면 상위테이블-하위테이블 relationship 을 볼수 있음. 그대신 c.r_constraint_name=p.constraint_name 해줌.
테이블 상세 도표
PHP DB 연동
oci_fetch_array
- used during a while loop, basically deals with only one array at a time and thus only one entry in the data table at a time.
oci_fetch_all
- returns the number of rows in the 2 dimensional array --> which are displayed as columns when drawn on paper, like this:
for oci_fetch_all, 공간복잡도가 올라가는 대신 시간복잡도가 내려감. And the opposite for oci_fetch_array.
그리고 when you use oci_fetch_all($result, $row), you can do the oci_free_statement($result) sooner since you already have all the data you need in $row.
Side note: Concatenation