Databases and SELECT
Databases and tables
A database stores information in tables. A table is a grid, a bit like a spreadsheet:
- each row is one record — for example, one student;
- each column is one field — for example, the student's name or score.
This course uses a small table called student. It has 5 records and 4 fields: id, name, form, and score.
데이터베이스와 표
데이터베이스는 표 형태로 정보를 저장합니다. 표는 격자 형태이며 스프레드시트와 유사합니다:
- 각 행은 하나의 레코드—예를 들어 한 명의 학생—를 나타냅니다;
- 각 열은 하나의 필드—예를 들어 학생의 이름이나 점수—를 의미합니다.
이 과정에서는 student이라는 작은 표를 사용합니다. 이 표에는 5개의 기록과 4개의 필드가 있습니다: id, name, form, 그리고 score.
Asking for data with SELECT
To read data from a table you write a query with SELECT.
The simplest query asks for every column of every row. The star * means "all columns":
SELECTchooses the columns —*means all of them.FROM studentsays which table to read.
The database replies with a result table (also called a result set): the rows your query asked for.
SELECT로 데이터 요청하기
표에서 데이터를 읽으려면 SELECT을 사용하여 쿼리를 작성합니다.
가장 간단한 쿼리는 모든 행의 모든 열을 요청합니다. 별표 *는 "모든 열"을 의미합니다:
SELECT * FROM student;
SELECT은 열을 선택합니다 —*은 모든 열을 의미합니다.FROM student은 읽을 표를 지정합니다.
데이터베이스는 결과 표(또는 결과셋)를 반환합니다. 이는 쿼리가 요청한 행들입니다.
A few rules
- Keywords like
SELECTandFROMare often written in capitals so they stand out. - End each statement with a semicolon
;. - An empty cell is shown as
NULL, which means "no value".
Now try it. Click Run to see the output, then Check answer.
몇 가지 규칙
SELECT와FROM같은 키워드는 두드러지도록 대문자로 자주 쓰입니다.- 각 문장의 끝에는 세미콜론
;을 넣습니다. - 빈 셀은
NULL로 표시되며, 이는 "값 없음"을 의미합니다.
이제 시도해 보세요. 출력 결과를 보려면 Run을 클릭하고, 다음에 Check answer를 클릭하세요.
Common mistakes
- End a query with a semicolon:
SELECT ... FROM table;. SELECT *returns every column — name only the ones you need.
흔한 실수
- 쿼리의 끝에는 세미콜론을 넣습니다:
SELECT ... FROM table;. SELECT *은 모든 열을 반환하므로 — 필요할 때만 열 이름을 나열하세요.
SELECT … FROM … WHERE
WHERE keeps rows, then SELECT keeps columns — step through it.
Show the whole student table — every column and every row. Use SELECT * FROM ...;.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.
Now keep only some columns and some rows. Show just the name and score of students in form 11A. Pick the two columns and add a WHERE form = '11A'.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.