/ W3SCHOOLS

W3schools - SQL_INSERT / Math_Function

이 페이지는 다음에 대한 공부 기록입니다
Lecture에서 배웠던 내용을 복습하며 작성했습니다

찾으시는 정보가 있으시다면
주제별reference를 이용하시거나
우측 상단에 있는 검색기능을 이용해주세요

INSERT INTO

Is used to insert new records in a table

Syntax

-- Specify both the column names and the values to be inserted
INSERT INTO table_name(colum1,colum2,)
VALUES(value1, value2,);
--- If add values for all the columns of the table, do not need to specify the column names in the SQL query
INSERT INTO table_name
VALUES (value1, value2,);

NULL

A field with a NULL is a field with no value

If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field

Then, the field will be saved with a NULL value

It is different from a zero value or a field that contains space

A field with a NULL value is one that has been left blank during record creation

IS NULL and IS NOT NULL operator can test for NULL values

UPDATE

Is used to modify the existing records in a table

Syntax

UPDATE table_name
SET column1 = value1, column2 = value2,
WHERE condition;

DELETE

Is used to delete existing records in a table

Syntax

DELETE FROM table_name WHERE condition;

SELECT TOP

Is used to specify the number of records to return

Syntax

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s)
FETCH FIRST number ROWS ONLY;
-- Can use `PERCENT` instead of number ex) 50 PERCENT

MIN() / MAX()

Return the smallest / largest value of the seleted column

Syntax

SELECT MIN(column_name) -- vice versa
FROM table_name
WHERE condition;

COUNT() / AVG() / SUM()

COUNT() : returns the number of rows that matches a specified criterion

AVG() : returns the average value of a numeric column

SUM() : returns the total sum of a numeric column