Database16 [MySQL] 사용자 정의 변수 사용법 SET @start = 1, @finish = 10; SELECT @start := 1, @finish := 10; SET 이나 SELECT를 이용하여 초기화 후 사용 SELECT * FROM places WHERE place BETWEEN @start AND @finish; ref : https://stackoverflow.com/questions/11754781/how-to-declare-a-variable-in-mysql 2022. 2. 15. [SQL] DISTINCT 사용법 SELECT DISTINCT Country FROM Customers; country 필드 중복을 제거한 결과 출력 SELECT COUNT(DISTINCT Country) FROM Customers; 중복 제거한 country 수 ref : https://www.w3schools.com/sql/sql_distinct.asp 2022. 2. 6. [PostgreSQL] 인덱스 생성 방법 CREATE INDEX index_name ON table_name [USING method] ( column_name [ASC | DESC] [NULLS {FIRST | LAST }], ... ); USING method : 인덱스 방식 지정, btree가 기본값 ASC | DESC : 정렬 방법 지정, ASC가 기본값 NULLS {FIRST | LAST} : NULL값들을 정렬하는 기준, NULLS LAST가 기본값, NULL이 마지막에 온다 ref : https://www.postgresqltutorial.com/postgresql-indexes/postgresql-create-index/ 2022. 1. 5. [MySQL] 외래키 걸려있는 테이블 비우기 mysql> SET foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec) mysql> drop table users; Query OK, 0 rows affected (0.00 sec) mysql> SET foreign_key_checks = 1; Query OK, 0 rows affected (0.00 sec) drop을 truncate로 바꾸면 비울 수 있다. ref : https://zetawiki.com/wiki/MySQL_%EC%99%B8%EB%9E%98%ED%82%A4_%EC%A0%81%EC%9A%A9_%ED%85%8C%EC%9D%B4%EB%B8%94_%EC%82%AD%EC%A0%9C 2021. 7. 19. 이전 1 2 3 4 다음