Skip to Content
SQL 시작하기
book

SQL 시작하기

by Thomas Nield
May 2025
Beginner to intermediate
134 pages
1h 46m
Korean
O'Reilly Media, Inc.
Content preview from SQL 시작하기

10장. 데이터 관리

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

이전 장에서는 데이터베이스를 만드는 방법뿐만 아니라 데이터베이스를 잘 만드는 방법을 배웠습니다. 잘 고려된 테이블 디자인, 열 제약 조건 및 관계는 테이블에 데이터를 넣기 시작하면 그 진가를 발휘합니다. 강력한 테이블 디자인과 테이블 간의 관계를 잘 고려하면 효율적이고 쉽게 조인할 수 있습니다. 고객 주소와 같이 데이터를 변경해야 하는 경우, 여러 곳이 아닌 한 곳에서만 변경하면 됩니다. 잘못된 데이터가 들어오는 경우, 데이터베이스에 입력되지 않도록 충분히 합리적인 제약 조건을 설정했으면 좋겠습니다.

이 장에서는 INSERT, DELETE, UPDATE 레코드를 작성하는 방법을 배웁니다. 다행히도 이와 같은 작업을 작성하는 것은 SELECT 문을 작성하는 것보다 훨씬 간단합니다.

이러한 SQL 쓰기 작업은 사람이 직접 수행할 필요가 없습니다. 소프트웨어(Java, Python 또는 기타 코딩 언어로 작성된)는 종종 사람과 동일한 방식으로 데이터를 읽고 쓰기 위해 SQL 문을 생성하고 실행하지만 훨씬 더 효율적으로 수행합니다. 이 책의 범위를 벗어나지만 코딩 언어와 관련된 내용은 다음 장에서 다룰 예정입니다.

삽입

관계형 데이터베이스에서 데이터는 데이터베이스가 먼저 레코드를 수신하는 경우에만 존재합니다. INSERT 문은 바로 이 작업을 수행하여 데이터베이스에 레코드를 삽입합니다. 레코드에 채울 필드를 선택할 수 있으며, 나머지 필드는 null이거나 기본값을 사용합니다.

INSERT 먼저 ATTENDEE 레코드를 지난 장에서 만든 SurgeTech 데이터베이스에 추가합니다. 데이터베이스에 자신을 추가하는 INSERT 은 다음과 같이 표시되어야 합니다. 자신의 이름과 함께 다음 문을 실행합니다:

INSERT INTO ATTENDEE (FIRST_NAME, LAST_NAME)
VALUES ('Thomas','Nield')

이 문장을 세분화해 보겠습니다:

INSERT INTO ATTENDEE (FIRST_NAME, LAST_NAME)
VALUES ('Thomas','Nield')

먼저 ATTENDEE 테이블에 레코드를 삽입한다고 선언하고, 채우기로 선택한 필드는 FIRST_NAMELAST_NAME 입니다:

INSERT INTO ATTENDEE (FIRST_NAME, LAST_NAME)
VALUES ('Thomas','Nield')

그런 다음 각 필드에 대한 값을 지정합니다. 필드를 선언한 순서와 동일한 순서로 값을 지정합니다. 'Thomas'FIRST_NAME 에 해당하고 'Nield'LAST_NAME 에 해당합니다.

SELECT * FROM ATTENDEE 을 실행하여 INSERT 이 들어왔는지 확인합니다. 당연히 이제 레코드가 존재합니다(그림 10-1).

그림 10-1. 참석자 테이블에 새로 삽입된 레코드

여기서 관찰해야 할 사항이 많이 있습니다. INSERT ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle Database 11g Release 2 Performance Tuning Tips & Techniques

Oracle Database 11g Release 2 Performance Tuning Tips & Techniques

Richard Niemiec

Publisher Resources

ISBN: 9798341656307