Time does not change us. It just unfolds us.

Programming

SQL 기초중에기초중에기초 문법

소젬 2022. 2. 11. 16:46

SQL 기초중에기초중에기초 문법 확인하긔

 

ORDER BY : 정렬

SELECT column_name
FROM table_name
WHERE condition
[ORDER BY] {column, expression} [ASC | DESC];

  • ASC : 오름차순 정렬 (기본 값)
  • DESC : 내림차순 정렬

 

INSERT : 데이터 삽입

INSERT INTO table_name(field_name1, field_name2, ...)
VALUES(field_value1, field_value2, ...), (field_value1, field_value2, ...);

INSERT INTO TEAM(ID, NAME, COUNTRY)
VALUES (1, "Tottenham Hotspur", "England");

 

DELETE : 데이터 삭제

DELETE FROM table_name
WHERE field_name1 = field_value1, field_name2 = field_value2, ...;

DELETE FROM TEAM
WHERE NAME="Tottenham";

 

SELECT : 데이터 조회

SELECT field_name1, field_name2
FROM table_name
WHERE field_name1 = field_value1, field_name2 = field_value2;

SELECT *
FROM TEAM
WHERE COUNTRY="Korea";

 

UPDATE : 테이블 수정

UPDATE table_name
SET field_name1 = field_value1, field_name2 = field_value2;
WHERE field_name1 = field_value1, field_name2 = field_value2;

UPDATE TEAM
SET NAME="토트넘 핫스퍼"
WHERE NAME="Tottenham Hotspur";

'Programming' 카테고리의 다른 글

[Java]리소스 확인  (0) 2021.10.28
[JAVA]자바 스트림(Stream)  (0) 2021.10.25
[GO]Golang  (0) 2021.10.22