docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
---
|
||||
id: sql-tutorial-index
|
||||
title: "SQL Tutorial"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Tutorial", "SQL MOC", "Topic_SQL index", "SQL 목차"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.90
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "moc", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Tutorial]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Map of Content (MOC) for the W3Schools SQL Tutorial — the root that links every SQL knowledge page in this topic folder. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- This folder (`Topic_SQL`) wikifies the **W3Schools SQL Tutorial** (left-sidebar tutorial menu), one knowledge page per document, in P-Reinforce v3.1 format — following the same convention as `Topic_HTML` / `Topic_CSS` / `Topic_JavaScript`. [S1]
|
||||
- Scope: **tutorial + "Learning by examples" pages only**. The large reference dumps (SQL Keywords Reference, MySQL/SQL Server/MS Access Functions — ~290 individual function-stub pages) and non-knowledge meta pages (Quiz, Exercises, Editor, Certificate, Bootcamp, Syllabus, Study Plan, Training, Server) are **excluded by design**. [S1]
|
||||
- **Progress:** **67 of 67 planned docs complete — SQL category done.**
|
||||
- Every page roots its Knowledge Graph back to this `[[SQL Tutorial]]` node.
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
|
||||
### Basics
|
||||
- [[SQL Intro]] ✅
|
||||
- [[SQL Syntax]] ✅
|
||||
|
||||
### Querying & Filtering
|
||||
- [[SQL Select]] ✅
|
||||
- [[SQL Select Distinct]] ✅
|
||||
- [[SQL Where]] ✅
|
||||
- [[SQL Order By]] ✅
|
||||
- [[SQL And]] ✅
|
||||
- [[SQL Or]] ✅
|
||||
- [[SQL Not]] ✅
|
||||
- [[SQL Like]] ✅
|
||||
- [[SQL Wildcards]] ✅
|
||||
- [[SQL In]] ✅
|
||||
- [[SQL Between]] ✅
|
||||
- [[SQL Aliases]] ✅
|
||||
|
||||
### Joins & Set Operations
|
||||
- [[SQL Joins]] ✅
|
||||
- [[SQL Inner Join]] ✅
|
||||
- [[SQL Left Join]] ✅
|
||||
- [[SQL Right Join]] ✅
|
||||
- [[SQL Full Join]] ✅
|
||||
- [[SQL Self Join]] ✅
|
||||
- [[SQL Union]] ✅
|
||||
- [[SQL Union All]] ✅
|
||||
|
||||
### Grouping & Aggregation
|
||||
- [[SQL Group By]] ✅
|
||||
- [[SQL Having]] ✅
|
||||
- [[SQL Aggregate Functions]] ✅
|
||||
- [[SQL Min]] ✅
|
||||
- [[SQL Max]] ✅
|
||||
- [[SQL Count]] ✅
|
||||
- [[SQL Sum]] ✅
|
||||
- [[SQL Avg]] ✅
|
||||
|
||||
### Data Modification
|
||||
- [[SQL Insert Into]] ✅
|
||||
- [[SQL Null Values]] ✅
|
||||
- [[SQL Update]] ✅
|
||||
- [[SQL Delete]] ✅
|
||||
- [[SQL Select Top]] ✅
|
||||
- [[SQL Select Into]] ✅
|
||||
- [[SQL Insert Into Select]] ✅
|
||||
|
||||
### Conditional & Logic
|
||||
- [[SQL Exists]] ✅
|
||||
- [[SQL Any]] ✅
|
||||
- [[SQL All]] ✅
|
||||
- [[SQL Case]] ✅
|
||||
- [[SQL Null Functions]] ✅
|
||||
|
||||
### Procedures & Comments
|
||||
- [[SQL Stored Procedures]] ✅
|
||||
- [[SQL Comments]] ✅
|
||||
- [[SQL Operators]] ✅
|
||||
|
||||
### Database & Table Management
|
||||
- [[SQL Create DB]] ✅
|
||||
- [[SQL Drop DB]] ✅
|
||||
- [[SQL Backup DB]] ✅
|
||||
- [[SQL Create Table]] ✅
|
||||
- [[SQL Drop Table]] ✅
|
||||
- [[SQL Alter Table]] ✅
|
||||
- [[SQL Constraints]] ✅
|
||||
- [[SQL Not Null]] ✅
|
||||
- [[SQL Unique]] ✅
|
||||
- [[SQL Primary Key]] ✅
|
||||
- [[SQL Foreign Key]] ✅
|
||||
- [[SQL Check]] ✅
|
||||
- [[SQL Default]] ✅
|
||||
- [[SQL Create Index]] ✅
|
||||
- [[SQL Auto Increment]] ✅
|
||||
- [[SQL Dates]] ✅
|
||||
- [[SQL Views]] ✅
|
||||
|
||||
### Security
|
||||
- [[SQL Injection]] ✅
|
||||
- [[SQL Parameters]] ✅
|
||||
- [[SQL Prepared Statements]] ✅
|
||||
|
||||
### Deployment & Reference
|
||||
- [[SQL Hosting]] ✅
|
||||
- [[SQL Data Types]] ✅
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
67 knowledge documents generated, all grounded in the corresponding W3Schools pages via a Playwright-based extraction pipeline (adapted from the Datacollector_MAC project's `web_extract.mjs`, with added noise-stripping for sidebar/footer).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[10_Wiki]]
|
||||
- **관련 개념:** [[SQL Intro]], [[SQL Select]], [[SQL Create Table]], [[Topic_Programming]]
|
||||
- **참조 맥락:** HTML/CSS/JavaScript에 이어 W3Schools 지식화 시리즈의 다음 카테고리. 완료 후 Python/PHP/MySQL 등 나머지 카테고리가 동일한 규칙으로 이어진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Tutorial — https://www.w3schools.com/sql/
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Created SQL Tutorial MOC and linked 5 pilot-batch pages (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: sql-aggregate-functions
|
||||
title: "SQL Aggregate Functions"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Aggregate functions", "SQL 집계 함수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "aggregate", "groupby"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_aggregate_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Aggregate Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An aggregate function reduces a set of values to a single value, most often per GROUP BY group, and by convention ignores NULLs (except COUNT(*)). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Aggregate function** — performs a calculation on a set of values and returns a single value. [S1]
|
||||
- **Common aggregate functions** — `MIN()` (smallest value), `MAX()` (largest value), `COUNT()` (row count), `SUM()` (total), `AVG()` (average). [S1]
|
||||
- **Pairs with GROUP BY** — GROUP BY splits the result-set into groups, and the aggregate function returns one value per group. [S1]
|
||||
- **NULL handling** — aggregate functions ignore NULL values, except `COUNT(*)`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **NULL-exclusion is the default, COUNT(\*) is the exception** — every aggregate function silently skips NULLs, but `COUNT(*)` counts rows regardless of NULL content — a distinction worth remembering to avoid miscounted results. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 개론 페이지로, 각 함수(MIN/MAX/COUNT/SUM/AVG)는 이어지는 개별 챕터에서 문법과 예제가 상세히 다뤄진다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 개론 뒤에 MIN/MAX/COUNT/SUM/AVG 각각의 전용 챕터가 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (개론 페이지, 각 함수 챕터에서 코드 제공).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Min]], [[SQL Max]], [[SQL Count]], [[SQL Sum]], [[SQL Avg]], [[SQL Group By]]
|
||||
- **참조 맥락:** MIN/MAX/COUNT/SUM/AVG 다섯 함수 챕터의 상위 개론 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Aggregate Functions — https://www.w3schools.com/sql/sql_aggregate_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Aggregate Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: sql-aliases
|
||||
title: "SQL Aliases"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Alias", "AS keyword", "SQL 별칭"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "alias", "join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_alias.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Aliases]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An alias, created with AS, gives a column or table a temporary, more readable name that exists only for the duration of the query — and becomes essential once tables are joined. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Alias** — created with the `AS` keyword; makes a column name more readable; only exists for the duration of that query. [S1]
|
||||
- **Column alias syntax** — `SELECT column_name AS alias_name FROM table_name;`. [S1]
|
||||
- **Table alias syntax** — `SELECT column_name(s) FROM table_name AS alias_name;`. [S1]
|
||||
- **Aliases with spaces** — wrap in square brackets `[My Great Products]` or double quotes `"My Great Products"` (support varies by DB system). [S1]
|
||||
- **Concatenation alias** — combining multiple columns into one output column needs an alias to name the combined result. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Table alias for joins** — short aliases like `c` for customers and `o` for orders make multi-table JOIN queries shorter and more readable: `FROM customers AS c JOIN orders AS o ON c.customerID = o.customerID`. [S1]
|
||||
- **Vendor-specific concatenation syntax** — the same "combine 4 address columns into one" intent needs different syntax per DB: `+` (SQL Server), `CONCAT()` (MySQL), `||` (Oracle). [S1]
|
||||
- **When aliases matter most** — the source lists: multiple tables in a query, functions used in the query, long/unclear column names, and combined columns. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic column alias: `SELECT CustomerID AS ID, CustomerName AS Customer FROM Customers;`. [S1]
|
||||
- Alias with spaces (bracket form): `SELECT ProductName AS [My Great Products] FROM Products;`. [S1]
|
||||
- Alias with spaces (quote form): `SELECT ProductName AS "My Great Products" FROM Products;`. [S1]
|
||||
- Concatenated column alias (SQL Server): `SELECT CustomerName, Address + ', ' + PostalCode + ' ' + City + ', ' + Country AS Address FROM Customers;`. [S1]
|
||||
- Same intent in MySQL: `SELECT CustomerName, CONCAT(Address,', ',PostalCode,', ',City,', ',Country) AS Address FROM Customers;`. [S1]
|
||||
- Same intent in Oracle: `SELECT CustomerName, (Address || ', ' || PostalCode || ' ' || City || ', ' || Country) AS Address FROM Customers;`. [S1]
|
||||
- Table alias: `SELECT * FROM Customers AS Persons;` and, for joins, `FROM customers AS c JOIN orders AS o ON c.customerID = o.customerID`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **문자열 연결 문법이 DB마다 다름**: 동일한 "4개 컬럼 합치기" 요구가 SQL Server(`+`), MySQL(`CONCAT()`), Oracle(`||`)에서 각각 다른 연산자로 구현됨 — 표준 SQL이 아닌 방언별 차이. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 JOIN 챕터 전체에서 테이블 별칭(c, o 등)이 관용적으로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Column alias (SQL):
|
||||
```sql
|
||||
SELECT CustomerID AS ID, CustomerName AS Customer
|
||||
FROM Customers;
|
||||
```
|
||||
Table alias for a join (SQL):
|
||||
```sql
|
||||
SELECT c.CustomerName, o.OrderID
|
||||
FROM customers AS c
|
||||
JOIN orders AS o ON c.customerID = o.customerID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL Joins]], [[SQL Inner Join]]
|
||||
- **참조 맥락:** 다중 테이블 JOIN 쿼리를 읽기 쉽게 만드는 표준 관용구 — 이후 모든 JOIN 챕터의 전제 지식.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Aliases — https://www.w3schools.com/sql/sql_alias.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Aliases" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: sql-all
|
||||
title: "SQL All"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL ALL Operator", "ALL operator"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "all", "subquery"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_all.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL All]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
ALL compares a value against every value returned by a subquery, evaluating to TRUE only if EVERY comparison holds — the "every row must match" counterpart to ANY. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **ALL operator** — compares a value to every value returned by a subquery; TRUE only if every value in the result-set meets the condition. [S1]
|
||||
- **Typical usage** — commonly used with WHERE and HAVING statements. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table_name WHERE column_name operator ALL (subquery);` where `operator` is a standard comparison operator. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **All-or-nothing semantics** — because ALL requires every subquery value to satisfy the condition, an equality comparison (`= ALL`) against a subquery with varied values will almost always be FALSE unless the subquery happens to return a single repeated value. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Products where ALL matching order detail rows have Quantity = 10 (returns FALSE in the worked example, because the Quantity column has many different values, not only 10): [S1]
|
||||
```sql
|
||||
SELECT ProductName
|
||||
FROM Products
|
||||
WHERE ProductID = ALL (
|
||||
SELECT ProductID
|
||||
FROM OrderDetails
|
||||
WHERE Quantity = 10
|
||||
);
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — ANY와 대비해서 "적어도 하나 vs. 전부 만족"을 구분해 이해해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
ALL with a comparison operator (SQL):
|
||||
```sql
|
||||
SELECT ProductName
|
||||
FROM Products
|
||||
WHERE ProductID = ALL (
|
||||
SELECT ProductID
|
||||
FROM OrderDetails
|
||||
WHERE Quantity = 10
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Any]], [[SQL In]], [[SQL Having]]
|
||||
- **참조 맥락:** 서브쿼리 결과 전부를 만족해야 하는 조건에 사용 — ANY(하나라도 만족)와 대비.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL ALL Operator — https://www.w3schools.com/sql/sql_all.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL ALL Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: sql-alter-table
|
||||
title: "SQL Alter Table"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL ALTER TABLE Statement", "ALTER TABLE", "SQL 테이블 수정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "altertable"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_alter.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Alter Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
ALTER TABLE covers six common structural operations — add/drop/rename/modify a column, add a constraint, rename the table — with syntax that fragments by vendor for renaming and modifying columns. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **ALTER TABLE statement** — adds, deletes, or modifies columns in an existing table, and adds/drops constraints. [S1]
|
||||
- **Common operations** — Add column, Drop column, Rename column, Modify column, Add constraint, Rename table. [S1]
|
||||
- **Add column** — `ALTER TABLE table_name ADD column_name datatype;`. [S1]
|
||||
- **Drop column** — `ALTER TABLE table_name DROP COLUMN column_name;` (not allowed on some database systems). [S1]
|
||||
- **Rename column** — `ALTER TABLE table_name RENAME COLUMN old_name to new_name;` (SQL Server instead uses `EXEC sp_rename`). [S1]
|
||||
- **Modify column** — `ALTER COLUMN ...` (SQL Server/MS Access) vs. `MODIFY ...` (MySQL/Oracle). [S1]
|
||||
- **Add constraint** — `ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint_definition;`. [S1]
|
||||
- **Rename table** — `ALTER TABLE table_name RENAME TO new_table_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Vendor fragmentation on rename/modify** — renaming a column and modifying a column's type both require different syntax on SQL Server vs. MySQL/Oracle — the two operations most likely to trip up cross-database code. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Add a column: `ALTER TABLE Customers ADD Email varchar(255);`. [S1]
|
||||
- Modify a column with a new constraint (MySQL/Oracle): `ALTER TABLE Customers MODIFY Email varchar(100) NOT NULL;`. [S1]
|
||||
- Add a named CHECK constraint: `ALTER TABLE Members ADD CONSTRAINT CHK_Age CHECK (Age >= 18);`. [S1]
|
||||
- Rename a table: `ALTER TABLE Customers RENAME TO Clients;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **동일 의도, 다른 문법**: 컬럼 이름 변경/타입 변경이 SQL Server(`sp_rename`/`ALTER COLUMN`)와 MySQL/Oracle(`MODIFY`)에서 서로 다른 키워드를 요구함이 소스에서 명시적으로 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이미 생성된 테이블의 스키마를 점진적으로 진화시킬 때(마이그레이션) 쓰이는 핵심 문법이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Add a column then a constraint (SQL):
|
||||
```sql
|
||||
ALTER TABLE Customers
|
||||
ADD Email varchar(255);
|
||||
|
||||
ALTER TABLE Members
|
||||
ADD CONSTRAINT CHK_Age CHECK (Age >= 18);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Create Table]], [[SQL Constraints]], [[SQL Not Null]], [[SQL Check]]
|
||||
- **참조 맥락:** 스키마 마이그레이션(컬럼/제약조건 추가·수정)의 기본 문법 — 벤더별 문법 차이를 항상 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL ALTER TABLE Statement — https://www.w3schools.com/sql/sql_alter.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL ALTER TABLE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: sql-and
|
||||
title: "SQL And"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL AND Operator", "AND operator", "SQL 논리곱"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "and", "operators", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_and.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL And]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The AND operator filters records so that a row is returned only when ALL chained conditions in the WHERE clause are true. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **AND operator** — combines multiple conditions in a WHERE clause; a record is returned only if every condition is TRUE. [S1]
|
||||
- **Syntax** — `SELECT ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...;`. [S1]
|
||||
- **AND vs. OR** — AND requires all conditions true; OR requires at least one condition true. [S1]
|
||||
- **Combining AND and OR** — parentheses control evaluation grouping when mixing the two operators. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Parenthesize when mixing AND/OR** — `WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%')` gives the intended grouped result; omitting the parentheses changes which rows match because AND/OR precedence is not what the un-parenthesized reading suggests. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **괄호로 그룹화** | 의도한 대로 정확한 결과, 가독성 향상 | 코드가 약간 길어짐 | AND/OR를 섞어 쓸 때 항상 |
|
||||
| **괄호 생략** | 짧음 | 연산자 우선순위로 인해 의도와 다른 결과가 나올 위험 | 단일 연산자만 사용할 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Filter on two conditions: `SELECT * FROM Customers WHERE Country = 'Spain' AND CustomerName LIKE 'G%';`. [S1]
|
||||
- Filter on three conditions: `WHERE Country = 'Brazil' AND City = 'Rio de Janeiro' AND CustomerID > 50;`. [S1]
|
||||
- Mixed AND/OR, correctly grouped with parentheses: `WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%');` — without the parentheses, the same text returns a different (wider) result set, since it becomes "Spain AND starts-with-G" OR "starts-with-R regardless of country". [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 괄호 유무에 따라 동일해 보이는 조건식이 다른 결과를 낼 수 있다는 점이 소스 내에서 직접 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — WHERE 절 다중 조건 필터링에서 OR/NOT과 함께 가장 빈번히 재사용되는 연산자다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Multiple AND conditions (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Brazil'
|
||||
AND City = 'Rio de Janeiro'
|
||||
AND CustomerID > 50;
|
||||
```
|
||||
Correctly grouped AND + OR (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%');
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL Or]], [[SQL Not]]
|
||||
- **참조 맥락:** WHERE 절 다중 조건 결합의 기본 연산자 — OR/NOT과 세트로 이해해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL AND Operator — https://www.w3schools.com/sql/sql_and.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL AND Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: sql-any
|
||||
title: "SQL Any"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL ANY Operator", "ANY operator"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "any", "subquery"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_any_all.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Any]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
ANY compares a value against every value returned by a subquery, evaluating to TRUE if at least one comparison holds — pairing a standard comparison operator with a subquery result set. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **ANY operator** — compares a value to every value returned by a subquery; TRUE if at least one value in the result-set satisfies the condition. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table_name WHERE column_name operator ANY (subquery);` where `operator` is a standard comparison operator (`=`, `<>`, `!=`, `>`, `>=`, `<`, `<=`). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **At-least-one semantics** — `= ANY (subquery)` reads as "equals at least one value in the subquery result", making ANY effectively behave like IN when the operator is `=`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Products that have any order with Quantity = 10 (TRUE, since some orders do have Quantity 10): [S1]
|
||||
```sql
|
||||
SELECT ProductName FROM Products
|
||||
WHERE ProductID = ANY (
|
||||
SELECT ProductID
|
||||
FROM OrderDetails
|
||||
WHERE Quantity = 10
|
||||
);
|
||||
```
|
||||
- Same structure with `Quantity > 99` (TRUE, some orders exceed 99) vs. `Quantity > 1000` (FALSE, none exceed 1000) — showing ANY's truth value depends entirely on whether the subquery's condition is met by at least one row. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — ALL 연산자와 짝을 이뤄 "적어도 하나 vs. 전부" 조건을 대비해서 이해해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
ANY with a comparison operator (SQL):
|
||||
```sql
|
||||
SELECT ProductName FROM Products
|
||||
WHERE ProductID = ANY (
|
||||
SELECT ProductID
|
||||
FROM OrderDetails
|
||||
WHERE Quantity = 10
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL All]], [[SQL In]], [[SQL Exists]]
|
||||
- **참조 맥락:** 서브쿼리 결과 중 "하나라도 만족"하는지 확인할 때 사용 — ALL(전부 만족)과 대비.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL ANY Operator — https://www.w3schools.com/sql/sql_any_all.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL ANY Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: sql-auto-increment
|
||||
title: "SQL Auto Increment"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL AUTO INCREMENT Field", "AUTO_INCREMENT", "IDENTITY", "AUTOINCREMENT", "SEQUENCE"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "autoincrement", "primarykey"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_autoincrement.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Auto Increment]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every vendor auto-generates unique primary key numbers, but under a different keyword and mechanism — MySQL's AUTO_INCREMENT, SQL Server's IDENTITY, Access's AUTOINCREMENT, and Oracle's standalone SEQUENCE object requiring an explicit nextval() call. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Auto-increment field** — a numeric column that automatically generates a unique number when a new record is inserted; typically the PRIMARY KEY. [S1]
|
||||
- **MySQL** — `AUTO_INCREMENT` keyword; default start 1, increments by 1; restart value via `ALTER TABLE ... AUTO_INCREMENT = 100;`. [S1]
|
||||
- **SQL Server** — `IDENTITY(seed, increment)`, e.g. `IDENTITY(1,1)`. [S1]
|
||||
- **MS Access** — `AUTOINCREMENT` keyword, optionally `AUTOINCREMENT(seed, increment)`. [S1]
|
||||
- **Oracle** — no inline keyword; requires a standalone `SEQUENCE` object and explicit `sequence.nextval` on insert. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Insert without specifying the key** — in MySQL/SQL Server/Access, an INSERT simply omits the auto-increment column and the value is generated automatically. [S1]
|
||||
- **Oracle is the odd one out** — Oracle requires you to explicitly reference `seq_person.nextval` in the INSERT statement itself, rather than the column being silently populated. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **MySQL AUTO_INCREMENT / SQL Server IDENTITY / Access AUTOINCREMENT** | 컬럼 정의만으로 자동 생성, INSERT가 간단 | 벤더 종속 문법 | 해당 벤더 사용 시 기본 선택 |
|
||||
| **Oracle SEQUENCE** | 여러 테이블이 공유 가능, 세밀한 제어(cache, start, increment) | INSERT마다 `.nextval` 명시 필요, 별도 객체 관리 | Oracle 사용 시 유일한 방법 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQL: `CREATE TABLE Persons (Personid int AUTO_INCREMENT PRIMARY KEY, ...);`. [S1]
|
||||
- SQL Server: `CREATE TABLE Persons (Personid int IDENTITY(1,1) PRIMARY KEY, ...);`. [S1]
|
||||
- Oracle: `CREATE SEQUENCE seq_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;` then `INSERT INTO Persons (Personid, FirstName, LastName) VALUES (seq_person.nextval, 'Lars', 'Monsen');`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **벤더 4개 모두 문법이 다름**: 동일한 "자동 증가" 요구가 AUTO_INCREMENT/IDENTITY/AUTOINCREMENT/SEQUENCE로 완전히 다르게 구현됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — PRIMARY KEY 컬럼에 값을 수동 지정하지 않고 자동 생성하고 싶을 때 표준적으로 쓰이는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
MySQL and Oracle equivalents (SQL):
|
||||
```sql
|
||||
-- MySQL
|
||||
CREATE TABLE Persons (
|
||||
Personid int AUTO_INCREMENT PRIMARY KEY,
|
||||
LastName varchar(255) NOT NULL
|
||||
);
|
||||
-- Oracle
|
||||
CREATE SEQUENCE seq_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;
|
||||
INSERT INTO Persons (Personid, FirstName, LastName)
|
||||
VALUES (seq_person.nextval, 'Lars', 'Monsen');
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Primary Key]], [[SQL Insert Into]], [[SQL Create Table]]
|
||||
- **참조 맥락:** PRIMARY KEY 값을 자동 생성해야 할 때 사용 — 벤더별 문법 차이가 크므로 사용 중인 DB를 먼저 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL AUTO INCREMENT Field — https://www.w3schools.com/sql/sql_autoincrement.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL AUTO INCREMENT Field" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: sql-avg
|
||||
title: "SQL Avg"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL AVG() Function", "AVG function", "SQL 평균"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "avg", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_avg.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Avg]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
AVG() returns a numeric column's mean, ignoring NULLs, and doubles as a comparison baseline when nested as a subquery in a WHERE clause. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **AVG() function** — returns the average value of a numeric column; ignores NULL values. [S1]
|
||||
- **Syntax** — `SELECT AVG(column_name) FROM table_name WHERE condition;`. [S1]
|
||||
- **AVG() with GROUP BY** — returns the average per group. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **AVG() as a subquery baseline** — `WHERE Price > (SELECT AVG(Price) FROM Products)` uses AVG() inside a subquery to compare each row against the overall average — a reusable pattern for "above/below average" filters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic average: `SELECT AVG(Price) FROM Products;`. [S1]
|
||||
- With WHERE: `SELECT AVG(Price) FROM Products WHERE CategoryID = 1;`. [S1]
|
||||
- With alias: `SELECT AVG(Price) AS [average price] FROM Products;`. [S1]
|
||||
- Above-average filter via subquery: `SELECT * FROM Products WHERE Price > (SELECT AVG(Price) FROM Products);`. [S1]
|
||||
- With GROUP BY: `SELECT AVG(Price) AS AveragePrice, CategoryID FROM Products GROUP BY CategoryID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "평균 이상/이하" 필터링은 실무 리포트에서 흔한 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Above-average filter using AVG() as subquery (SQL):
|
||||
```sql
|
||||
SELECT * FROM Products
|
||||
WHERE Price > (SELECT AVG(Price) FROM Products);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Aggregate Functions]], [[SQL Group By]], [[SQL Where]]
|
||||
- **참조 맥락:** 평균값 계산 및 평균 대비 비교 필터링의 기본 함수.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL AVG() Function — https://www.w3schools.com/sql/sql_avg.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL AVG() Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: sql-backup-db
|
||||
title: "SQL Backup DB"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL BACKUP DATABASE Statement", "BACKUP DATABASE", "differential backup"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "backup", "sqlserver"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_backup_db.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Backup DB]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
BACKUP DATABASE (SQL Server) creates a full backup to disk, and WITH DIFFERENTIAL creates a faster, smaller backup capturing only changes since the last full backup. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **BACKUP DATABASE statement** — creates a full backup of an existing SQL Server database. [S1]
|
||||
- **Syntax** — `BACKUP DATABASE databasename TO DISK = 'filepath';`. [S1]
|
||||
- **BACKUP WITH DIFFERENTIAL** — captures only data changed since the last full backup; requires at least one prior full backup. [S1]
|
||||
- **Syntax (differential)** — `BACKUP DATABASE databasename TO DISK = 'filepath' WITH DIFFERENTIAL;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Store backups on a different drive** — placing the backup on a separate drive from the original database protects against losing both to the same disk failure. [S1]
|
||||
- **Full-then-differential strategy** — a differential backup reduces backup time by only capturing changes, but depends on a prior full backup existing. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full backup: `BACKUP DATABASE testDB TO DISK = 'D:\backups\testDB.bak';`. [S1]
|
||||
- Differential backup: `BACKUP DATABASE testDB TO DISK = 'D:\backups\testDB.bak' WITH DIFFERENTIAL;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — DROP DATABASE 같은 되돌릴 수 없는 작업 전에 선행되어야 하는 안전장치다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Full and differential backup (SQL Server):
|
||||
```sql
|
||||
BACKUP DATABASE testDB
|
||||
TO DISK = 'D:\backups\testDB.bak';
|
||||
|
||||
BACKUP DATABASE testDB
|
||||
TO DISK = 'D:\backups\testDB.bak'
|
||||
WITH DIFFERENTIAL;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Create DB]], [[SQL Drop DB]]
|
||||
- **참조 맥락:** 데이터베이스 삭제/변경 등 위험한 작업 이전에 항상 선행되어야 할 안전장치.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL BACKUP DATABASE Statement — https://www.w3schools.com/sql/sql_backup_db.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL BACKUP DATABASE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-between
|
||||
title: "SQL Between"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL BETWEEN Operator", "BETWEEN operator", "SQL 범위 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "between", "range", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_between.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Between]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
BETWEEN selects values within an inclusive range — numbers, text (alphabetical range), or dates — and can be negated with NOT BETWEEN or combined with IN. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **BETWEEN operator** — selects values within a specified range; the range is inclusive of both boundary values. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;`. [S1]
|
||||
- **NOT BETWEEN** — selects values outside the specified range. [S1]
|
||||
- **Value types** — works with numbers, text (alphabetical ordering), and dates. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **BETWEEN + IN combo** — `WHERE Price BETWEEN 10 AND 20 AND CategoryID IN (1,2,3);` layers a range filter with a set-membership filter. [S1]
|
||||
- **Date format discipline** — date BETWEEN comparisons require the literal format to match the database's date format convention (e.g. `'YYYY-MM-DD'`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Numeric range: `SELECT * FROM Products WHERE Price BETWEEN 10 AND 20;`. [S1]
|
||||
- Negated numeric range: `WHERE Price NOT BETWEEN 10 AND 20;`. [S1]
|
||||
- Text (alphabetical) range: `WHERE ProductName BETWEEN 'Geitost' AND 'Louisiana Hot Spiced Okra' ORDER BY ProductName;`. [S1]
|
||||
- Date range: `WHERE OrderDate BETWEEN '1996-07-01' AND '1996-07-31';` selects orders placed in July 1996. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 가격 범위 필터, 날짜 범위 리포트 등 실무 쿼리에서 흔히 재사용되는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Numeric range (SQL):
|
||||
```sql
|
||||
SELECT * FROM Products
|
||||
WHERE Price BETWEEN 10 AND 20;
|
||||
```
|
||||
Date range (SQL):
|
||||
```sql
|
||||
SELECT * FROM Orders
|
||||
WHERE OrderDate BETWEEN '1996-07-01' AND '1996-07-31';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL In]], [[SQL Not]]
|
||||
- **참조 맥락:** 숫자/텍스트/날짜 범위 필터링이 필요한 쿼리의 기본 문법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL BETWEEN Operator — https://www.w3schools.com/sql/sql_between.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL BETWEEN Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: sql-case
|
||||
title: "SQL Case"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CASE Expression", "CASE expression", "SQL 조건식"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "case", "conditional"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_case.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Case]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
CASE works like an if-then-else chain inside a query — it stops at the first true condition, falls back to ELSE, and returns NULL if nothing matches and there's no ELSE. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **CASE expression** — defines different results based on specified conditions within an SQL statement. [S1]
|
||||
- **Short-circuit evaluation** — stops at the first true condition and returns its result, like an if-then-else statement. [S1]
|
||||
- **ELSE fallback** — if no condition is true, returns the ELSE value; without ELSE and no match, returns NULL. [S1]
|
||||
- **Syntax** — `CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 ... ELSE default_result END;`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Categorize products by price into a new derived column: [S1]
|
||||
```sql
|
||||
SELECT ProductName, Price,
|
||||
CASE
|
||||
WHEN Price < 20 THEN 'Low Cost'
|
||||
WHEN Price BETWEEN 20 AND 50 THEN 'Medium Cost'
|
||||
ELSE 'High Cost'
|
||||
END AS PriceCategory
|
||||
FROM Products;
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 가격 구간처럼 값을 범주화하는 파생 컬럼을 만들 때 전형적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
CASE for value categorization (SQL):
|
||||
```sql
|
||||
SELECT ProductName, Price,
|
||||
CASE
|
||||
WHEN Price < 20 THEN 'Low Cost'
|
||||
WHEN Price BETWEEN 20 AND 50 THEN 'Medium Cost'
|
||||
ELSE 'High Cost'
|
||||
END AS PriceCategory
|
||||
FROM Products;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Between]], [[SQL Aliases]], [[SQL Null Functions]]
|
||||
- **참조 맥락:** 값 기반 분기/범주화 파생 컬럼이 필요한 모든 쿼리의 기본 조건식.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL CASE Expression — https://www.w3schools.com/sql/sql_case.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL CASE Expression" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: sql-check
|
||||
title: "SQL Check"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CHECK Constraint", "CHECK constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "check", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_check.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Check]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
CHECK enforces an arbitrary boolean condition on a column (or combination of columns) — an INSERT/UPDATE that would evaluate the condition to FALSE is aborted entirely. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **CHECK constraint** — ensures values in a column satisfy a specific condition; evaluates to TRUE or FALSE, and FALSE aborts the entire INSERT/UPDATE with an error. [S1]
|
||||
- **On CREATE TABLE** — inline, e.g. `Age int CHECK (Age >= 18)`. [S1]
|
||||
- **Named, multi-column CHECK** — `CONSTRAINT chk_PersonAge CHECK (Age >= 18 AND City = 'Sandnes')` combines multiple column conditions under one name. [S1]
|
||||
- **On ALTER TABLE** — `ALTER TABLE Persons ADD CHECK (Age >= 18);` or the named/multi-column form via `ADD CONSTRAINT`. [S1]
|
||||
- **Dropping** — `DROP CONSTRAINT chk_PersonAge;` (SQL Server/Oracle/Access) vs. `DROP CHECK chk_PersonAge;` (MySQL). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **드롭 문법 차이**: SQL Server/Oracle/Access는 `DROP CONSTRAINT`, MySQL은 `DROP CHECK`를 사용. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single-column CHECK: `CREATE TABLE Persons (ID int PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int CHECK (Age >= 18));`. [S1]
|
||||
- Named, multi-column CHECK: `CONSTRAINT chk_PersonAge CHECK (Age >= 18 AND City = 'Sandnes')`. [S1]
|
||||
- Add to existing table: `ALTER TABLE Persons ADD CHECK (Age >= 18);`. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — DEFAULT/NOT NULL만으로 표현할 수 없는 임의 비즈니스 규칙(나이 제한, 값 범위)을 강제할 때 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Named CHECK across two columns (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int PRIMARY KEY,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
City varchar(255),
|
||||
CONSTRAINT chk_PersonAge CHECK (Age >= 18 AND City = 'Sandnes')
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Default]], [[SQL Not Null]]
|
||||
- **참조 맥락:** 임의의 비즈니스 규칙을 컬럼 값에 강제할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL CHECK Constraint — https://www.w3schools.com/sql/sql_check.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL CHECK Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: sql-comments
|
||||
title: "SQL Comments"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL comment syntax", "SQL 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_comments.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Comments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SQL supports single-line (`--`) and multi-line (`/* */`) comments, ignored by the database engine, useful both for documentation and for temporarily disabling parts of a statement — except in Microsoft Access, which supports neither. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Purpose** — explain SQL code, or temporarily prevent execution of code (for debugging); comments are ignored by the database engine. [S1]
|
||||
- **Single-line comments** — start with `--` and continue to the end of the line. [S1]
|
||||
- **Multi-line comments** — start with `/*` and end with `*/`; any text between is ignored. [S1]
|
||||
- **MS Access exception** — comments are not supported in Microsoft Access databases. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Comment-out-to-disable** — appending `--` or wrapping in `/* */` is used not just for documentation but as a quick way to disable a clause, a whole statement, or several statements at once without deleting code. [S1]
|
||||
- **Inline partial comment** — a multi-line comment can mask just part of a line/statement (e.g. commenting out one column or one OR-branch) while the rest still executes. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single-line as explanation: `-- Selects all German customers` followed by the query. [S1]
|
||||
- Single-line to comment out the end of a line: `SELECT * FROM Customers -- WHERE City='Berlin';`. [S1]
|
||||
- Single-line to disable an entire statement: `-- SELECT * FROM Customers;` followed by a different active statement. [S1]
|
||||
- Multi-line as explanation: `/* Selects all German customers from Berlin */` followed by the query. [S1]
|
||||
- Multi-line to disable several statements at once. [S1]
|
||||
- Multi-line to mask part of a column list: `SELECT CustomerName, /*City,*/ Country FROM Customers;`. [S1]
|
||||
- Multi-line to mask part of an OR chain inside a WHERE clause. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **MS Access는 주석을 지원하지 않음** — 다른 모든 SQL 방언과 다른 예외 사항으로 소스에 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 디버깅 중 쿼리 일부를 임시로 비활성화하는 용도로 실무에서 흔히 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Single-line and multi-line comments (SQL):
|
||||
```sql
|
||||
-- Selects all German customers
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Germany';
|
||||
|
||||
/* Selects all German customers
|
||||
from Berlin */
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Germany' AND City = 'Berlin';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Syntax]]
|
||||
- **참조 맥락:** SQL 코드 문서화 및 디버깅 시 쿼리 일부를 비활성화할 때 사용 — MS Access에서는 지원되지 않음에 유의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Comments — https://www.w3schools.com/sql/sql_comments.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: sql-constraints
|
||||
title: "SQL Constraints"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Constraint Types", "SQL 제약조건"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_constraints.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Constraints]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Constraints are rules enforced on table data that abort any action violating them, specifiable either at table creation or added afterward via ALTER TABLE. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL constraints** — rules for data in a table; prevent invalid data insertion and ensure accuracy/reliability; a violating action is aborted. [S1]
|
||||
- **When specified** — at CREATE TABLE time, or later via ALTER TABLE. [S1]
|
||||
- **Constraint types** — `NOT NULL`, `UNIQUE`, `PRIMARY KEY`, `FOREIGN KEY`, `CHECK`, `DEFAULT`, `CREATE INDEX`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **PRIMARY KEY as composite constraint** — the source frames PRIMARY KEY as "a combination of NOT NULL and UNIQUE", clarifying it isn't a separate primitive but a composition of two simpler constraints. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 개론 페이지로, NOT NULL/UNIQUE/PRIMARY KEY/FOREIGN KEY/CHECK/DEFAULT/CREATE INDEX 각각은 이어지는 개별 챕터에서 문법과 예제가 상세히 다뤄진다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 개론 뒤에 7가지 제약조건 각각의 전용 챕터가 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (개론 페이지, 각 제약조건 챕터에서 코드 제공).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Not Null]], [[SQL Unique]], [[SQL Primary Key]], [[SQL Foreign Key]], [[SQL Check]], [[SQL Default]], [[SQL Create Index]]
|
||||
- **참조 맥락:** 7가지 제약조건 챕터의 상위 개론 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Constraints — https://www.w3schools.com/sql/sql_constraints.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Constraints" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: sql-count
|
||||
title: "SQL Count"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL COUNT() Function", "COUNT function", "SQL 개수 세기"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "count", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_count.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Count]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
COUNT() behaves differently depending on its argument — `COUNT(*)` counts all rows including NULLs, `COUNT(column)` counts non-null values, and `COUNT(DISTINCT column)` counts unique non-null values. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **COUNT() function** — returns the number of rows matching a specified criterion. [S1]
|
||||
- **Syntax** — `SELECT COUNT([DISTINCT] column_name | *) FROM table_name WHERE condition;`. [S1]
|
||||
- **`COUNT(*)`** — counts the total number of rows, including NULL values. [S1]
|
||||
- **`COUNT(column_name)`** — counts only non-null values in that column. [S1]
|
||||
- **`COUNT(DISTINCT column_name)`** — counts only unique, non-null values. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Argument choice changes semantics** — the three COUNT variants answer three different questions (total rows / filled-in rows / unique values), so picking the right one matters for correctness, not just style. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Total row count: `SELECT COUNT(*) FROM Products;`. [S1]
|
||||
- Non-null count for a column: `SELECT COUNT(ProductName) FROM Products;`. [S1]
|
||||
- Unique non-null count: `SELECT COUNT(DISTINCT Price) FROM Products;`. [S1]
|
||||
- With WHERE: `SELECT COUNT(ProductID) FROM Products WHERE Price > 20;`. [S1]
|
||||
- With alias: `SELECT COUNT(*) AS [Number of records] FROM Products;`. [S1]
|
||||
- With GROUP BY: `SELECT COUNT(*) AS [Number of records], CategoryID FROM Products GROUP BY CategoryID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SELECT DISTINCT 챕터에서 이미 소개된 `COUNT(DISTINCT ...)` 패턴이 여기서 정식으로 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Three COUNT variants (SQL):
|
||||
```sql
|
||||
SELECT COUNT(*) FROM Products; -- all rows, incl. NULLs
|
||||
SELECT COUNT(ProductName) FROM Products; -- non-null values only
|
||||
SELECT COUNT(DISTINCT Price) FROM Products; -- unique non-null values
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Aggregate Functions]], [[SQL Select Distinct]], [[SQL Group By]]
|
||||
- **참조 맥락:** 행 개수를 세는 모든 리포트의 기본 함수 — DISTINCT와 결합해 고유값 개수도 셀 수 있다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL COUNT() Function — https://www.w3schools.com/sql/sql_count.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL COUNT() Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: sql-create-db
|
||||
title: "SQL Create DB"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CREATE DATABASE Statement", "CREATE DATABASE", "SQL 데이터베이스 생성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "createdatabase"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_create_db.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Create DB]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
CREATE DATABASE provisions a new SQL database and requires administrative privileges, with a vendor-specific command to list existing databases afterward. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **CREATE DATABASE statement** — creates a new SQL database. [S1]
|
||||
- **Requires admin privileges** — creating a database needs administrative access. [S1]
|
||||
- **Syntax** — `CREATE DATABASE database_name;`. [S1]
|
||||
- **Listing databases** — `SELECT name FROM sys.databases;` (SQL Server) or `SHOW DATABASES;` (MySQL). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create a database: `CREATE DATABASE testDB;`. [S1]
|
||||
- Verify creation (SQL Server): `SELECT name FROM sys.databases;`. [S1]
|
||||
- Verify creation (MySQL): `SHOW DATABASES;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 CREATE TABLE 챕터에서 이 데이터베이스 안에 실제 테이블을 만드는 과정으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Create and verify a database (SQL):
|
||||
```sql
|
||||
CREATE DATABASE testDB;
|
||||
-- MySQL
|
||||
SHOW DATABASES;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Drop DB]], [[SQL Create Table]], [[SQL Backup DB]]
|
||||
- **참조 맥락:** 데이터베이스/테이블 관리 챕터군의 시작점 — 관리자 권한이 필요함에 유의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL CREATE DATABASE Statement — https://www.w3schools.com/sql/sql_create_db.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL CREATE DATABASE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: sql-create-index
|
||||
title: "SQL Create Index"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CREATE INDEX Statement", "CREATE INDEX", "CREATE UNIQUE INDEX"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_create_index.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Create Index]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Indexes speed up data retrieval on frequently-searched columns, but slow down writes since the index itself must be updated — a classic read/write trade-off, not a free performance win. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **CREATE INDEX statement** — creates indexes on table columns to speed up data retrieval; invisible to users, purely a performance aid. [S1]
|
||||
- **Write cost trade-off** — updating indexed tables is more time-consuming, since indexes must also be updated — so index only columns that are frequently searched. [S1]
|
||||
- **Non-unique vs. unique** — `CREATE INDEX` allows duplicate values; `CREATE UNIQUE INDEX` does not. [S1]
|
||||
- **Multi-column index** — listing multiple columns creates a composite index. [S1]
|
||||
- **DROP INDEX** — vendor-specific syntax to remove an index. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **DROP INDEX 문법이 4가지 벤더 모두 다름**: SQL Server(`DROP INDEX table.index`), MySQL(`ALTER TABLE ... DROP INDEX`), MS Access(`DROP INDEX index ON table`), DB2/Oracle(`DROP INDEX index`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Non-unique index: `CREATE INDEX idx_lastname ON Persons (LastName);`. [S1]
|
||||
- Composite index: `CREATE INDEX idx_lname_fname ON Persons (LastName, FirstName);`. [S1]
|
||||
- Unique index syntax: `CREATE UNIQUE INDEX index_name ON table_name (column1, column2, ...);`. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자주 검색되는 컬럼(예: LastName)에만 선택적으로 적용해야 쓰기 성능 저하를 최소화할 수 있다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Single and composite index (SQL):
|
||||
```sql
|
||||
CREATE INDEX idx_lastname
|
||||
ON Persons (LastName);
|
||||
|
||||
CREATE INDEX idx_lname_fname
|
||||
ON Persons (LastName, FirstName);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Unique]], [[SQL Where]]
|
||||
- **참조 맥락:** 자주 검색되는 컬럼의 조회 성능을 높일 때 사용 — 쓰기 성능 저하와 트레이드오프임에 유의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL CREATE INDEX Statement — https://www.w3schools.com/sql/sql_create_index.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL CREATE INDEX Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: sql-create-table
|
||||
title: "SQL Create Table"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CREATE TABLE Statement", "CREATE TABLE", "SQL 테이블 생성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "createtable"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_create_table.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Create Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
CREATE TABLE defines a new table's columns, data types, and constraints, and a variant lets a new table be created directly from another table's SELECT result. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **CREATE TABLE statement** — creates a new table in a database. [S1]
|
||||
- **Syntax** — `CREATE TABLE table_name (column1 datatype constraint, column2 datatype constraint, ...);`. [S1]
|
||||
- **Constraint parameter** — optional; specifies data-integrity rules like PRIMARY KEY or NOT NULL. [S1]
|
||||
- **CREATE TABLE ... AS SELECT** — creates a new table populated from an existing table's query result. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Column defaults to nullable** — columns without an explicit `NOT NULL` allow NULL values by default. [S1]
|
||||
- **Filtered table clone** — `CREATE TABLE new_table AS SELECT ... FROM existing_table WHERE ...;` both creates the schema and populates it from a filtered subset in one step. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic table with a primary key and a required column: [S1]
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
PersonID int PRIMARY KEY,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Address varchar(255),
|
||||
City varchar(255)
|
||||
);
|
||||
```
|
||||
- Create-and-populate from an existing table: `CREATE TABLE GermanCustomers AS SELECT * FROM Customers WHERE Country = 'Germany';`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 생성 직후 INSERT INTO로 데이터를 채우는 것이 자연스러운 다음 단계로 안내된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic table definition (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
PersonID int PRIMARY KEY,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Address varchar(255),
|
||||
City varchar(255)
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Insert Into]], [[SQL Data Types]], [[SQL Drop Table]]
|
||||
- **참조 맥락:** 테이블 생성의 기본 문법 — Constraints/Data Types 챕터와 함께 이해해야 완전해진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL CREATE TABLE Statement — https://www.w3schools.com/sql/sql_create_table.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL CREATE TABLE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: sql-data-types
|
||||
title: "SQL Data Types"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Data Types for MySQL, SQL Server, and MS Access", "SQL 데이터 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "datatypes", "mysql", "sqlserver", "msaccess"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_datatypes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every column needs a declared data type, but the same conceptual type (string, integer, date) has a different name, size limit, and storage cost in MySQL, SQL Server, and MS Access — always check the target database's documentation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Data type** — defines what value a column can hold (integer, character, money, date/time, binary, etc.); every column requires a name and a data type. [S1]
|
||||
- **Three broad families (per vendor)** — String, Numeric, and Date/Time types recur across MySQL and SQL Server, with a different set of specific type names each. [S1]
|
||||
- **MySQL string types** — `CHAR(size)`, `VARCHAR(size)`, `BINARY(size)`, `VARBINARY(size)`, `BLOB` family, `TEXT` family, `ENUM`, `SET`. [S1]
|
||||
- **MySQL numeric types** — `BIT`, `TINYINT`/`SMALLINT`/`MEDIUMINT`/`INT`/`BIGINT`, `BOOL`/`BOOLEAN`, `DECIMAL`/`DEC`, `FLOAT`, `DOUBLE`. [S1]
|
||||
- **MySQL date/time types** — `DATE`, `DATETIME`, `TIMESTAMP`, `TIME`, `YEAR`. [S1]
|
||||
- **SQL Server string types** — `char(n)`, `varchar(n)`/`varchar(max)`, `nchar(n)`, `nvarchar(n)`/`nvarchar(max)`, `binary(n)`, `varbinary(n)`/`varbinary(max)`. [S1]
|
||||
- **SQL Server numeric types** — `bit`, `tinyint`/`smallint`/`int`/`bigint`, `decimal(p,s)`/`numeric(p,s)`, `smallmoney`/`money`, `float(n)`, `real`. [S1]
|
||||
- **SQL Server date/time types** — `date`, `time`, `datetime`, `datetime2`, `smalldatetime`, `datetimeoffset`, `timestamp` (not a real date — an auto-updating row-version number). [S1]
|
||||
- **SQL Server other types** — `sql_variant`, `uniqueidentifier` (GUID), `xml`, `cursor`, `table`. [S1]
|
||||
- **MS Access types** — `Text`, `Memo`, `Byte`, `Integer`, `Long`, `Single`, `Double`, `Currency`, `AutoNumber`, `Date/Time`, `Yes/No`, `Ole Object`, `Hyperlink`, `Lookup Wizard`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Same concept, different name and limit per vendor** — e.g. "auto-incrementing integer" appears as `AUTO_INCREMENT` column (MySQL), `IDENTITY` (SQL Server), or `AutoNumber` type (MS Access) — always cross-check the target vendor's docs rather than assume type names/sizes transfer. [S1]
|
||||
- **`TIMESTAMP` is a false friend** — in SQL Server, `timestamp` does NOT store a date/time; it's a unique auto-updating row-version number, unlike MySQL's `TIMESTAMP` which is a real date/time type. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 MySQL 8.4/SQL Server/MS Access 세 시스템의 String/Numeric/Date-Time(및 기타) 데이터 타입을 표로 정리한 레퍼런스 챕터다. 상세 표는 소스 원문을 참조. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **`TIMESTAMP`의 의미가 벤더마다 다름**: MySQL은 실제 날짜/시간 타입이지만, SQL Server의 `timestamp`는 자동 갱신되는 고유 행 버전 번호일 뿐 실제 시각을 나타내지 않는다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — CREATE TABLE/ALTER TABLE에서 컬럼 타입을 정할 때 항상 참조해야 하는 레퍼런스다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (데이터 타입 이름·설명·크기를 정리한 레퍼런스 표).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Create Table]], [[SQL Alter Table]], [[SQL Dates]]
|
||||
- **참조 맥락:** 테이블/컬럼 설계 시 항상 참조하는 타입 레퍼런스 — 벤더별 차이를 반드시 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Data Types for MySQL, SQL Server, and MS Access — https://www.w3schools.com/sql/sql_datatypes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: sql-dates
|
||||
title: "SQL Dates"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Working With Dates", "SQL 날짜"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "dates"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_dates.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Dates]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Matching a date literal against a datetime column silently returns nothing if the stored value carries a time component the literal doesn't — the hardest part of SQL dates is format alignment, not date logic itself. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **The core difficulty** — being sure the date format you insert/select matches the database column's format. [S1]
|
||||
- **MySQL date types** — `DATE` (YYYY-MM-DD), `DATETIME`/`TIMESTAMP` (YYYY-MM-DD HH:MI:SS), `TIME` (HH:MI:SS), `YEAR` (YYYY or YY). [S1]
|
||||
- **SQL Server date types** — `DATE`, `DATETIME`, `SMALLDATETIME`, `TIME`, `TIMESTAMP` (a unique number, not a date). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Time-component footgun** — a WHERE clause like `OrderDate='2025-11-11'` matches rows when the column is pure `DATE`, but silently returns zero rows once the column stores a time component too (e.g. `2025-11-11 13:23:44`), because exact string/value equality no longer holds. [S1]
|
||||
- **Keep dates time-free unless necessary** — the source explicitly recommends avoiding time-components in date columns to keep queries simple, unless the time is actually needed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Simple date match (works, no time component): `SELECT * FROM Orders WHERE OrderDate='2025-11-11'`. [S1]
|
||||
- Same query against a column that also stores time (returns NO rows, since exact match requires the time portion too): same query, different schema. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 "동일해 보이는 쿼리가 스키마에 따라 결과가 완전히 달라진다"는 점이 핵심 경고로 제시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "쿼리가 아무 결과도 안 준다"는 흔한 버그의 원인이 날짜/시간 포맷 불일치인 경우가 많다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Exact date match, no time component (SQL):
|
||||
```sql
|
||||
SELECT * FROM Orders WHERE OrderDate='2025-11-11';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Between]], [[SQL Data Types]], [[SQL Where]]
|
||||
- **참조 맥락:** 날짜/시간 컬럼을 다루는 모든 쿼리에서 포맷 불일치 버그를 예방하기 위해 참조.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Working With Dates — https://www.w3schools.com/sql/sql_dates.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Working With Dates" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: sql-default
|
||||
title: "SQL Default"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL DEFAULT Constraint", "DEFAULT constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "default", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_default.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Default]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
DEFAULT auto-fills a column with a fallback value when none is provided, and can hold a system function call (like the current date) instead of a static literal. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **DEFAULT constraint** — automatically inserts a default value for a column if no value is specified; applies to all new records. [S1]
|
||||
- **On CREATE TABLE** — e.g. `City varchar(255) DEFAULT 'Sandnes'`. [S1]
|
||||
- **System-value defaults** — functions like `CURRENT_DATE()` (MySQL) or `CAST(GETDATE() AS date)` (SQL Server) auto-populate the current date. [S1]
|
||||
- **On ALTER TABLE** — vendor-specific syntax to add or drop a DEFAULT after table creation (MySQL, SQL Server, MS Access, Oracle all differ). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **4개 벤더 모두 다른 ALTER 문법**: DEFAULT를 나중에 추가/제거하는 문법이 MySQL(`ALTER ... SET DEFAULT`/`DROP DEFAULT`), SQL Server(`ADD CONSTRAINT ... DEFAULT ... FOR col`), MS Access(`ALTER COLUMN ... SET DEFAULT`), Oracle(`MODIFY col DEFAULT ...`)에서 각각 다름. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Static default on creation: `City varchar(255) DEFAULT 'Sandnes'` inside CREATE TABLE. [S1]
|
||||
- System-value default (MySQL): `OrderDate date DEFAULT CURRENT_DATE()`. [S1]
|
||||
- System-value default (SQL Server): `OrderDate date DEFAULT CAST(GETDATE() AS date)`. [S1]
|
||||
- Add after creation (MySQL): `ALTER TABLE Persons ALTER City SET DEFAULT 'Sandnes';`. [S1]
|
||||
- Add after creation (SQL Server): `ALTER TABLE Persons ADD CONSTRAINT df_City DEFAULT 'Sandnes' FOR City;`. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 값이 비어있을 때 정적 기본값 또는 현재 날짜 같은 시스템 값을 자동 채우는 데 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Static and system-value defaults (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int PRIMARY KEY,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
City varchar(255) DEFAULT 'Sandnes'
|
||||
);
|
||||
-- MySQL system default
|
||||
CREATE TABLE Orders (
|
||||
ID int PRIMARY KEY,
|
||||
OrderNumber int NOT NULL,
|
||||
OrderDate date DEFAULT CURRENT_DATE()
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Check]], [[SQL Dates]]
|
||||
- **참조 맥락:** 값이 명시되지 않은 컬럼을 자동으로 채워야 할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL DEFAULT Constraint — https://www.w3schools.com/sql/sql_default.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL DEFAULT Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: sql-delete
|
||||
title: "SQL Delete"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL DELETE Statement", "DELETE statement", "SQL 삭제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "delete", "droptable"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_delete.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Delete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
DELETE removes rows from a table while keeping its structure intact — but omitting WHERE deletes every row, and only DROP TABLE removes the table itself. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **DELETE statement** — deletes existing records in a table. [S1]
|
||||
- **Syntax** — `DELETE FROM table_name WHERE condition;`. [S1]
|
||||
- **Delete all records, keep the table** — `DELETE FROM table_name;` (no WHERE) removes every row but preserves structure, attributes, and indexes. [S1]
|
||||
- **Delete the whole table** — `DROP TABLE table_name;` removes the table entirely, unlike DELETE. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **DELETE FROM table (WHERE 없음)** | 테이블 구조·속성·인덱스는 유지됨 | 모든 행이 삭제됨 | 데이터만 비우고 스키마는 재사용할 때 |
|
||||
| **DROP TABLE** | 테이블 자체와 모든 데이터·구조를 완전히 제거 | 되돌릴 수 없고 스키마도 사라짐 | 테이블 자체를 더 이상 쓰지 않을 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Delete a specific record: `DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';`. [S1]
|
||||
- Delete all records, keep table structure: `DELETE FROM Customers;`. [S1]
|
||||
- Delete the entire table: `DROP TABLE Customers;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. UPDATE와 마찬가지로 WHERE 누락 위험이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — DELETE(행 삭제)와 DROP TABLE(테이블 자체 삭제)의 구분은 실무에서 흔히 혼동되는 지점이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Delete matching rows (SQL):
|
||||
```sql
|
||||
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
|
||||
```
|
||||
Delete all rows, keep table (SQL):
|
||||
```sql
|
||||
DELETE FROM Customers;
|
||||
```
|
||||
Drop the table entirely (SQL):
|
||||
```sql
|
||||
DROP TABLE Customers;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Update]], [[SQL Where]], [[SQL Drop Table]]
|
||||
- **참조 맥락:** CRUD의 Delete 축 — DROP TABLE과 혼동하지 않는 것이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL DELETE Statement — https://www.w3schools.com/sql/sql_delete.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL DELETE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: sql-drop-db
|
||||
title: "SQL Drop DB"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL DROP DATABASE Statement", "DROP DATABASE", "SQL 데이터베이스 삭제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "dropdatabase"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_drop_db.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Drop DB]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
DROP DATABASE permanently deletes a database and every table, view, procedure, and row inside it — an irreversible, admin-only operation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **DROP DATABASE statement** — permanently deletes an existing SQL database, including all its content (tables, views, stored procedures, data). [S1]
|
||||
- **Requires admin privileges** — dropping a database needs administrative access. [S1]
|
||||
- **Syntax** — `DROP DATABASE databasename;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Irreversibility warning** — the source explicitly warns to "be careful" since everything in the database is destroyed at once — implying a backup (see [[SQL Backup DB]]) should precede this in practice. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Drop a database: `DROP DATABASE testDB;`. [S1]
|
||||
- Verify removal: `SHOW DATABASES;` (MySQL) or `SELECT name FROM sys.databases;` (SQL Server). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 되돌릴 수 없는 명령이므로 실행 전 BACKUP DATABASE를 선행하는 것이 안전한 관행이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Drop a database (SQL):
|
||||
```sql
|
||||
DROP DATABASE testDB;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Create DB]], [[SQL Backup DB]], [[SQL Drop Table]]
|
||||
- **참조 맥락:** 데이터베이스 전체를 영구 삭제할 때 사용 — 실행 전 백업이 사실상 필수.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL DROP DATABASE Statement — https://www.w3schools.com/sql/sql_drop_db.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL DROP DATABASE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: sql-drop-table
|
||||
title: "SQL Drop Table"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL DROP TABLE Statement", "DROP TABLE", "TRUNCATE TABLE", "SQL 테이블 삭제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "droptable", "truncate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_drop_table.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Drop Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
DROP TABLE permanently removes a table and all its content, blocked if another table's foreign key still references it — while TRUNCATE TABLE clears all rows but keeps the table structure intact. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **DROP TABLE statement** — permanently deletes an existing table and all its content. [S1]
|
||||
- **Syntax** — `DROP TABLE table_name;`, or safely `DROP TABLE IF EXISTS table_name;`. [S1]
|
||||
- **Foreign key blocking** — most databases refuse to drop a table still referenced by a foreign key constraint elsewhere; the constraint or dependent table must be removed first. [S1]
|
||||
- **TRUNCATE TABLE** — deletes all records in a table while keeping the table structure, columns, and constraints. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **DROP TABLE** | 테이블과 데이터를 완전히 제거 | 되돌릴 수 없고 구조도 사라짐, FK 참조 시 실패 | 테이블 자체가 더 이상 필요 없을 때 |
|
||||
| **TRUNCATE TABLE** | 구조·제약조건 유지하며 데이터만 빠르게 비움 | 개별 행 조건 삭제는 불가(전체 삭제만) | 구조는 재사용하되 데이터만 초기화할 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Safe drop with existence check: `DROP TABLE IF EXISTS Shippers;`. [S1]
|
||||
- Truncate (empty but keep structure): `TRUNCATE TABLE table_name;`. [S1]
|
||||
- FK constraint blocking: dropping a table referenced by another table's FOREIGN KEY requires removing the constraint or the dependent table first. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Delete 챕터에서 DROP TABLE이 이미 "행 삭제(DELETE)와 다르다"는 맥락으로 먼저 언급되었고, 여기서 IF EXISTS/FK 차단/TRUNCATE로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Safe drop and truncate (SQL):
|
||||
```sql
|
||||
DROP TABLE IF EXISTS Shippers;
|
||||
TRUNCATE TABLE table_name;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Delete]], [[SQL Foreign Key]], [[SQL Create Table]]
|
||||
- **참조 맥락:** 테이블 자체를 제거하거나 데이터만 비워야 할 때 사용 — FOREIGN KEY 참조가 걸려있는지 먼저 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL DROP TABLE Statement — https://www.w3schools.com/sql/sql_drop_table.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL DROP TABLE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: sql-exists
|
||||
title: "SQL Exists"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL EXISTS Operator", "EXISTS operator", "SQL 존재 확인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "exists", "subquery"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_exists.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Exists]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
EXISTS tests whether a correlated subquery returns any row at all, evaluating to TRUE the moment one match is found — a boolean existence check rather than a value comparison. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **EXISTS operator** — used in a WHERE clause to check whether a subquery returns any rows; TRUE if at least one row, FALSE otherwise. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table_name WHERE EXISTS (subquery);`. [S1]
|
||||
- **Correlated subquery** — the subquery typically references the outer query's table (e.g. `Products.SupplierID = Suppliers.supplierID`) to test existence per outer row. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Suppliers with at least one product priced under 10: [S1]
|
||||
```sql
|
||||
SELECT SupplierName
|
||||
FROM Suppliers
|
||||
WHERE EXISTS (
|
||||
SELECT ProductName
|
||||
FROM Products
|
||||
WHERE Products.SupplierID = Suppliers.supplierID AND Price < 10
|
||||
);
|
||||
```
|
||||
- Same pattern, different threshold (Price = 22), illustrating that EXISTS only cares about row presence, not the queried column's actual values. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — IN (SELECT ...)과 유사한 목적(서브쿼리 기반 필터링)이지만, EXISTS는 값이 아닌 행의 존재 여부만 확인한다는 차이가 있다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Correlated EXISTS subquery (SQL):
|
||||
```sql
|
||||
SELECT SupplierName
|
||||
FROM Suppliers
|
||||
WHERE EXISTS (
|
||||
SELECT ProductName
|
||||
FROM Products
|
||||
WHERE Products.SupplierID = Suppliers.supplierID AND Price < 10
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL In]], [[SQL Any]], [[SQL All]]
|
||||
- **참조 맥락:** 서브쿼리 결과의 "존재 여부"만 확인하면 되는 필터링에 사용 — 값 비교가 필요하면 IN/ANY/ALL을 대신 고려.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL EXISTS Operator — https://www.w3schools.com/sql/sql_exists.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL EXISTS Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: sql-foreign-key
|
||||
title: "SQL Foreign Key"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL FOREIGN KEY Constraint", "FOREIGN KEY constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "foreignkey", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_foreignkey.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Foreign Key]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
FOREIGN KEY links a child table's column to a parent table's PRIMARY KEY, blocking both invalid inserts into the child and deletes from the parent that would orphan child rows. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **FOREIGN KEY constraint** — establishes a link between two tables and prevents actions that would destroy that link. [S1]
|
||||
- **Child vs. parent table** — the table holding the foreign key column is the child table; the table holding the referenced primary key is the parent (referenced) table. [S1]
|
||||
- **Two-way protection** — blocks invalid inserts into the child (value must exist in the parent), and blocks deletes from the parent that would orphan matching child rows. [S1]
|
||||
- **Syntax (on create)** — `CONSTRAINT fk_Person FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)` inside `CREATE TABLE`. [S1]
|
||||
- **Syntax (on alter)** — `ALTER TABLE Orders ADD CONSTRAINT fk_Person FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Define on table creation: [S1]
|
||||
```sql
|
||||
CREATE TABLE Orders (
|
||||
OrderID int PRIMARY KEY,
|
||||
OrderNumber int NOT NULL,
|
||||
PersonID int,
|
||||
CONSTRAINT fk_Person
|
||||
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
|
||||
);
|
||||
```
|
||||
- Add to an existing table: `ALTER TABLE Orders ADD CONSTRAINT fk_Person FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);`. [S1]
|
||||
- Drop: `ALTER TABLE Orders DROP CONSTRAINT fk_Person;` (SQL Server/Oracle/Access) vs. `ALTER TABLE Orders DROP FOREIGN KEY fk_Person;` (MySQL). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **드롭 문법 차이**: SQL Server/Oracle/Access는 `DROP CONSTRAINT`, MySQL은 `DROP FOREIGN KEY`를 사용. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — DROP TABLE 챕터에서 이미 "FK로 참조되는 테이블은 바로 드롭할 수 없다"는 제약이 선행 언급되었다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
FOREIGN KEY on table creation (SQL):
|
||||
```sql
|
||||
CREATE TABLE Orders (
|
||||
OrderID int PRIMARY KEY,
|
||||
OrderNumber int NOT NULL,
|
||||
PersonID int,
|
||||
CONSTRAINT fk_Person
|
||||
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Primary Key]], [[SQL Drop Table]], [[SQL Inner Join]]
|
||||
- **참조 맥락:** 테이블 간 참조 무결성을 강제할 때 사용 — JOIN에서 활용되는 관계가 바로 이 제약으로 정의된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL FOREIGN KEY Constraint — https://www.w3schools.com/sql/sql_foreignkey.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL FOREIGN KEY Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: sql-full-join
|
||||
title: "SQL Full Join"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["FULL JOIN", "FULL OUTER JOIN", "SQL 전체 외부 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join", "full-join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join_full.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Full Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
FULL JOIN unions the behavior of LEFT and RIGHT JOIN — it keeps every row from both tables, filling NULL wherever the other side has no match, and can return very large result sets. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **FULL JOIN** — returns all rows when there is a match in either the left or right table. [S1]
|
||||
- **NULL-filling both sides** — an unmatched left row gets NULLs for all right-table columns, and vice versa. [S1]
|
||||
- **FULL JOIN == FULL OUTER JOIN** — the `OUTER` keyword is optional. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 FULL JOIN table2 ON table1.column_name = table2.column_name WHERE condition;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Size warning** — the source explicitly warns "FULL JOIN can potentially return very large result-sets!", making it something to use deliberately rather than by default. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All customers and all orders together, whether or not they match: `SELECT Customers.CustomerName, Orders.OrderID FROM Customers FULL JOIN Orders ON Customers.CustomerID = Orders.CustomerID;`. [S1]
|
||||
- Result includes rows with `CustomerName = Null` (orders with no matching customer) and rows with `OrderID = Null` (customers with no orders). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 데이터 정합성 점검(양쪽 테이블 모두에서 누락된 레코드 찾기)에 전형적으로 쓰이는 조인 유형이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Full outer join (SQL):
|
||||
```sql
|
||||
SELECT Customers.CustomerName, Orders.OrderID
|
||||
FROM Customers
|
||||
FULL JOIN Orders
|
||||
ON Customers.CustomerID = Orders.CustomerID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Joins]], [[SQL Left Join]], [[SQL Right Join]]
|
||||
- **참조 맥락:** 양쪽 테이블의 unmatched 행을 모두 보존해야 하는 데이터 정합성 점검 쿼리.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL FULL JOIN — https://www.w3schools.com/sql/sql_join_full.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL FULL JOIN" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: sql-group-by
|
||||
title: "SQL Group By"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL GROUP BY Statement", "GROUP BY clause", "SQL 그룹화"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "groupby", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_groupby.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Group By]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
GROUP BY collapses rows sharing the same value into summary rows, and is almost always paired with an aggregate function like COUNT/SUM/AVG to compute a value per group. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **GROUP BY statement** — groups rows with the same values into summary rows, e.g. "find the number of customers in each country". [S1]
|
||||
- **Pairs with aggregate functions** — COUNT(), MAX(), MIN(), SUM(), AVG() compute a single value per group. [S1]
|
||||
- **Syntax** — `SELECT column1, aggregate_function(column2), column3, ... FROM table_name WHERE condition GROUP BY column1, column3 ORDER BY column_name;`. [S1]
|
||||
- **GROUP BY with JOIN** — grouping works across joined tables, e.g. counting orders per shipper after a LEFT JOIN. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Group-then-sort-by-aggregate** — combining `GROUP BY` with `ORDER BY COUNT(...) DESC` ranks groups by their aggregate value, a very common "top categories" reporting pattern. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Count customers per country: `SELECT Country, COUNT(CustomerID) AS [Number of Customers] FROM Customers GROUP BY Country;`. [S1]
|
||||
- Same, sorted by count descending: `... GROUP BY Country ORDER BY COUNT(CustomerID) DESC;`. [S1]
|
||||
- GROUP BY with a JOIN: `SELECT Shippers.ShipperName, COUNT(Orders.OrderID) AS NumberOfOrders FROM Orders LEFT JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID GROUP BY ShipperName;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터인 HAVING이 GROUP BY 결과 자체를 필터링하는 방법을 확장한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Count rows per group, sorted by count (SQL):
|
||||
```sql
|
||||
SELECT Country, COUNT(CustomerID) AS [Number of Customers]
|
||||
FROM Customers
|
||||
GROUP BY Country
|
||||
ORDER BY COUNT(CustomerID) DESC;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Having]], [[SQL Aggregate Functions]], [[SQL Count]], [[SQL Order By]]
|
||||
- **참조 맥락:** 집계 리포트(카테고리별 집계, 랭킹) 작성의 핵심 문법 — HAVING과 함께 이해해야 완전해진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL GROUP BY Statement — https://www.w3schools.com/sql/sql_groupby.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL GROUP BY Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: sql-having
|
||||
title: "SQL Having"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL HAVING Clause", "HAVING clause", "SQL 그룹 조건절"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "having", "groupby", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_having.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Having]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
HAVING filters GROUP BY results based on aggregate conditions, applying AFTER grouping — unlike WHERE, which filters individual rows BEFORE grouping. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **HAVING clause** — filters the results of a GROUP BY query based on aggregate functions. [S1]
|
||||
- **WHERE vs. HAVING** — WHERE filters individual rows before grouping; HAVING filters groups after aggregation. [S1]
|
||||
- **Syntax** — `SELECT column1, aggregate_function(column2), column3, ... FROM table_name WHERE condition GROUP BY column1, column3 HAVING condition ORDER BY column_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **WHERE + GROUP BY + HAVING composition** — a query can filter rows first (WHERE), group them, then filter the resulting groups (HAVING) — e.g. restrict to two named employees, group by last name, then keep only groups with more than 25 orders. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Countries with more than 5 customers: `SELECT Country, COUNT(CustomerID) AS [Number of Customers] FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;`. [S1]
|
||||
- Same, sorted descending: `... GROUP BY Country HAVING COUNT(CustomerID) > 5 ORDER BY COUNT(CustomerID) DESC;`. [S1]
|
||||
- Employees with more than 10 orders, via JOIN + GROUP BY + HAVING: `SELECT Employees.LastName, COUNT(Orders.OrderID) AS NumberOfOrders FROM Orders INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID GROUP BY LastName HAVING COUNT(Orders.OrderID) > 10;`. [S1]
|
||||
- Combined WHERE + GROUP BY + HAVING: filter to two named employees first, then keep only those with more than 25 orders. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "N건 이상인 그룹만 보기" 같은 리포팅 쿼리에서 GROUP BY와 항상 짝을 이뤄 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Filter groups by aggregate condition (SQL):
|
||||
```sql
|
||||
SELECT Country, COUNT(CustomerID) AS [Number of Customers]
|
||||
FROM Customers
|
||||
GROUP BY Country
|
||||
HAVING COUNT(CustomerID) > 5;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Group By]], [[SQL Where]], [[SQL Aggregate Functions]]
|
||||
- **참조 맥락:** GROUP BY 결과 자체를 조건으로 걸러야 할 때 사용 — WHERE와 역할을 혼동하지 않는 것이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL HAVING Clause — https://www.w3schools.com/sql/sql_having.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL HAVING Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: sql-hosting
|
||||
title: "SQL Hosting"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL 호스팅"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "hosting", "mysql", "postgresql", "sqlserver", "oracle"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_hosting.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Hosting]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Choosing a database system for a web site's SQL hosting is a trade-off between cost, licensing, scalability, and vendor ecosystem — MySQL/PostgreSQL for low-cost open options, SQL Server/Oracle for high-traffic enterprise needs at a licensing cost. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL hosting requirement** — a web server needs access to a database system to store/retrieve data; if hosted by an ISP, a SQL hosting plan is needed. [S1]
|
||||
- **MySQL** — known for speed, reliability, ease of use; an inexpensive alternative to Microsoft/Oracle solutions. [S1]
|
||||
- **SQL Server** — popular for high-traffic, database-driven sites; strong integration with other Microsoft products, powerful tools, robust security. [S1]
|
||||
- **Oracle** — known for extreme scalability, performance, reliability, security; expensive licensing. [S1]
|
||||
- **PostgreSQL** — advanced features, high standards compliance, extensibility, strong data integrity; open-source and free. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **MySQL** | 빠르고 신뢰성 높음, 저비용 | 엔터프라이즈 기능은 상대적으로 단순 | 일반적인 웹사이트, 비용 최소화가 중요할 때 |
|
||||
| **PostgreSQL** | 표준 준수, 확장성, 강력한 데이터 무결성, 오픈소스 무료 | MySQL 대비 상대적으로 학습 곡선이 있을 수 있음 | 고급 기능/데이터 무결성이 중요한 오픈소스 선호 프로젝트 |
|
||||
| **SQL Server** | 고트래픽 사이트에 적합, MS 생태계 통합, 강력한 보안 | 라이선스 비용 | Microsoft 스택 위에서 고트래픽 서비스 운영 시 |
|
||||
| **Oracle** | 극한의 확장성·성능·신뢰성·보안 | 라이선스 비용이 매우 비쌈 | 최고 수준의 확장성이 필요한 대형 엔터프라이즈 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 SQL 호스팅을 위한 4대 주요 데이터베이스 소프트웨어(MySQL/SQL Server/Oracle/PostgreSQL)의 특징을 요약 비교하는 개론 챕터다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 웹사이트 배포 시 데이터베이스 벤더를 선택하는 의사결정 가이드 성격의 챕터다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (벤더 비교 개론 챕터).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Data Types]]
|
||||
- **참조 맥락:** 웹사이트에 사용할 데이터베이스 벤더를 선택할 때 참조하는 개론 비교 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Hosting — https://www.w3schools.com/sql/sql_hosting.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Hosting" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-in
|
||||
title: "SQL In"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL IN Operator", "IN operator", "SQL 포함 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "in", "subquery", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_in.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL In]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
IN is a shorthand for multiple OR conditions on the same column, and can take either a literal value list or a subquery result set. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **IN operator** — checks if a column's value matches any value within a provided list, functioning as shorthand for chained OR conditions. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...);`. [S1]
|
||||
- **NOT IN** — returns records whose value is NOT any of the listed values. [S1]
|
||||
- **IN (SELECT ...)** — the value list can be replaced with a subquery, returning rows present in the subquery's result. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **IN as OR-shorthand** — `WHERE Country IN ('Germany','France','UK')` is equivalent to, and shorter/more readable than, `WHERE Country='Germany' OR Country='France' OR Country='UK'`. [S1]
|
||||
- **Subquery membership test** — `WHERE CustomerID IN (SELECT CustomerID FROM Orders)` filters the outer query to rows whose key appears in a related table's query result — a lightweight alternative to a JOIN when only filtering (not selecting extra columns) is needed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Literal list form: `SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');` — equivalent longer form: `WHERE Country = 'Germany' OR Country = 'France' OR Country = 'UK';`. [S1]
|
||||
- Negated list form: `WHERE Country NOT IN ('Germany', 'France', 'UK');`. [S1]
|
||||
- Subquery form: `WHERE CustomerID IN (SELECT CustomerID FROM Orders);` returns customers who have placed at least one order. [S1]
|
||||
- Negated subquery form: `WHERE CustomerID NOT IN (SELECT CustomerID FROM Orders);` returns customers who have never placed an order. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 실제 예제에서 "74개 레코드가 반환되었으므로 17명의 고객이 주문이 없다"는 식으로 IN/NOT IN 결과를 상호 검증하는 방식이 소스에 등장한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Value-list IN (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country IN ('Germany', 'France', 'UK');
|
||||
```
|
||||
Subquery IN (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE CustomerID IN (SELECT CustomerID FROM Orders);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Or]], [[SQL Between]], [[SQL Exists]], [[SQL Where]]
|
||||
- **참조 맥락:** 동일 컬럼에 대한 다중 OR 조건이나 서브쿼리 멤버십 테스트가 필요할 때 재사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL IN Operator — https://www.w3schools.com/sql/sql_in.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL IN Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-injection
|
||||
title: "SQL Injection"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL 인젝션"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "security", "injection"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_injection.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Injection]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SQL injection exploits raw string concatenation of user input into a query — a tautology like `OR 1=1` or a batched `; DROP TABLE ...` can turn a single-row lookup into a full-table dump or destructive command. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL injection** — a code injection technique where attackers insert malicious SQL into user-input fields to read, modify, or delete sensitive data. [S1]
|
||||
- **Root cause** — building SQL strings by concatenating raw user input, e.g. `txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;`. [S1]
|
||||
- **Tautology injection (`1=1`)** — input like `105 OR 1=1` makes the WHERE clause always true, returning every row. [S1]
|
||||
- **Tautology injection (`""=""`)** — the same idea applied to string-quoted login fields (`" OR ""="`), bypassing username/password checks entirely. [S1]
|
||||
- **Batched statement injection** — a semicolon lets an attacker append an entirely separate destructive statement, e.g. `UserId = 105; DROP TABLE Suppliers;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Never trust concatenated input** — every example in the source traces back to the same root cause: building a SQL string by directly concatenating unescaped, unvalidated user input. [S1]
|
||||
- **The fix lives in the next two chapters** — the source explicitly defers the mitigation (SQL Parameters, SQL Prepared Statements) rather than covering it here. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Vulnerable pattern: `txtUserId = getRequestString("UserId"); txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;`. [S1]
|
||||
- Tautology exploit: input `105 OR 1=1` yields `SELECT * FROM Users WHERE UserId = 105 OR 1=1;`, returning ALL rows. [S1]
|
||||
- Login bypass exploit: input `" OR ""="` on both fields yields `SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""=""`, which is always true. [S1]
|
||||
- Batched destructive exploit: `SELECT * FROM Users WHERE UserId = 105; DROP TABLE Suppliers;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 두 챕터(SQL Parameters, SQL Prepared Statements)가 이 문제의 실제 해결책을 제시한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Vulnerable string-concatenation pattern (illustrative, NOT recommended):
|
||||
```
|
||||
txtUserId = getRequestString("UserId");
|
||||
txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Parameters]], [[SQL Prepared Statements]]
|
||||
- **참조 맥락:** 사용자 입력을 다루는 모든 쿼리 작성 전 반드시 인지해야 할 보안 위협 — 해결책은 다음 두 챕터.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Injection — https://www.w3schools.com/sql/sql_injection.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Injection" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: sql-inner-join
|
||||
title: "SQL Inner Join"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["INNER JOIN", "SQL 내부 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join", "inner-join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join_inner.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Inner Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
INNER JOIN — the default join type, so plain JOIN means the same thing — returns only rows that have a match in both tables, discarding anything unmatched. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **INNER JOIN** — returns only rows that have matching values in both tables. [S1]
|
||||
- **JOIN == INNER JOIN** — `JOIN` alone defaults to `INNER JOIN`; the parser treats them identically. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;`. [S1]
|
||||
- **Multi-table INNER JOIN** — more than two tables can be joined by chaining multiple `INNER JOIN` clauses. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Table-name qualification is a good habit** — prefixing column names with their table (`Products.ProductID`) avoids ambiguity errors when the same column name (e.g. `CategoryID`) exists in both joined tables. [S1]
|
||||
- **Unmatched rows silently vanish** — a product with no `CategoryID`, or with a `CategoryID` absent from the Categories table, is simply excluded from the result — a common footgun when INNER JOIN is used where LEFT JOIN was intended. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic two-table join: `SELECT ProductID, ProductName, CategoryName FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID;`. [S1]
|
||||
- Qualified column names to avoid ambiguity: `SELECT Products.ProductID, Products.ProductName, Categories.CategoryName FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID;`. [S1]
|
||||
- `JOIN` is shorthand for `INNER JOIN` — both produce identical results. [S1]
|
||||
- Joining three tables: `FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Aliases 챕터의 테이블 별칭(c, o)이 INNER JOIN 예제에서도 그대로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two-table INNER JOIN (SQL):
|
||||
```sql
|
||||
SELECT Products.ProductID, Products.ProductName, Categories.CategoryName
|
||||
FROM Products
|
||||
INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID;
|
||||
```
|
||||
Three-table INNER JOIN chain (SQL):
|
||||
```sql
|
||||
SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName
|
||||
FROM Orders
|
||||
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID
|
||||
INNER JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Joins]], [[SQL Left Join]], [[SQL Aliases]]
|
||||
- **참조 맥락:** 매칭되는 행만 필요한 조인 쿼리의 기본 유형 — LEFT/RIGHT/FULL JOIN과 대비해서 이해해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL INNER JOIN — https://www.w3schools.com/sql/sql_join_inner.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL INNER JOIN" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,103 @@
|
||||
---
|
||||
id: sql-insert-into
|
||||
title: "SQL Insert Into"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL INSERT INTO Statement", "INSERT statement", "SQL 삽입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "insert"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_insert.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Insert Into]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
INSERT INTO adds new records to a table, either by specifying columns and matching values explicitly or by supplying values for every column in table order, and it supports inserting multiple rows in one statement. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **INSERT INTO statement** — inserts new records into a table. [S1]
|
||||
- **Syntax 1 (explicit columns)** — `INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);`. [S1]
|
||||
- **Syntax 2 (all columns, no names)** — `INSERT INTO table_name VALUES (value1, value2, value3, ...);`, valid only if values are supplied for every column in the exact column order. [S1]
|
||||
- **Partial-column insert** — specific columns can be targeted (e.g. `CustomerName, City, Country`); unspecified columns are left `null` (or auto-generated for identity columns). [S1]
|
||||
- **Multi-row insert** — a single INSERT INTO statement can insert several rows by comma-separating multiple `VALUES(...)` groups. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Auto-increment omission** — when a column is an auto-increment primary key (e.g. `CustomerID`), it must NOT be given a value; the database generates it automatically. [S1]
|
||||
- **Column-order dependency** — Syntax 2's positional values must exactly match the table's column definition order, making it fragile to schema changes compared to Syntax 1. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **Syntax 1 (컬럼명 명시)** | 컬럼 순서에 안전하고 의도가 명확함, 일부 컬럼만 삽입 가능 | 타이핑이 더 김 | 프로덕션 코드, 일부 컬럼만 채울 때 |
|
||||
| **Syntax 2 (컬럼명 생략)** | 간결함 | 테이블 스키마가 바뀌면 깨지기 쉬움, 전체 컬럼 값이 반드시 필요 | 빠른 테스트/스크립트, 스키마가 고정적일 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Insert a full new record by omitting column names (values must follow table column order): [S1]
|
||||
```sql
|
||||
INSERT INTO Customers
|
||||
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
|
||||
```
|
||||
Note: `CustomerID`는 auto-increment 필드이므로 값을 지정하지 않아도 자동 생성된다. [S1]
|
||||
- Insert data only in specific columns (others become `null`): [S1]
|
||||
```sql
|
||||
INSERT INTO Customers (CustomerName, City, Country)
|
||||
VALUES ('Cardinal', 'Stavanger', 'Norway');
|
||||
```
|
||||
- Insert multiple rows in one statement by comma-separating value groups: [S1]
|
||||
```sql
|
||||
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
|
||||
VALUES
|
||||
('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'),
|
||||
('Greasy Burger', 'Per Olsen', 'Gateveien 15', 'Sandnes', '4306', 'Norway'),
|
||||
('Tasty Tee', 'Finn Egan', 'Streetroad 19B', 'Liverpool', 'L1 0AA', 'UK');
|
||||
```
|
||||
Note: 각 값 그룹은 쉼표(,)로 구분해야 한다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — INSERT INTO는 이후 SQL Insert Into Select(다른 테이블의 조회 결과를 삽입) 챕터의 선행 개념이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Insert full record, columns implied by table order (SQL):
|
||||
```sql
|
||||
INSERT INTO Customers
|
||||
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
|
||||
```
|
||||
Insert multiple rows in one statement (SQL):
|
||||
```sql
|
||||
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
|
||||
VALUES
|
||||
('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'),
|
||||
('Greasy Burger', 'Per Olsen', 'Gateveien 15', 'Sandnes', '4306', 'Norway');
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Null Values]], [[SQL Update]], [[SQL Insert Into Select]]
|
||||
- **참조 맥락:** 데이터 생성(Create)의 기본 문서 — Update/Delete와 함께 CRUD의 한 축을 담당.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL INSERT INTO Statement — https://www.w3schools.com/sql/sql_insert.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL INSERT INTO Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-insert-into-select
|
||||
title: "SQL Insert Into Select"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL INSERT INTO SELECT Statement", "INSERT INTO SELECT"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "insertintoselect"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_insert_into_select.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Insert Into Select]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
INSERT INTO SELECT copies rows from one existing table into another EXISTING table, leaving the target's current rows untouched — unlike SELECT INTO, which creates a brand-new table. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **INSERT INTO SELECT statement** — copies data from an existing table and inserts it into another existing table. [S1]
|
||||
- **Data type matching required** — source and target table column data types must match. [S1]
|
||||
- **Target rows preserved** — existing records in the target table are unaffected by the insert. [S1]
|
||||
- **Syntax (all columns)** — `INSERT INTO target_table SELECT * FROM source_table WHERE condition;` — requires column count/order to match exactly if names are omitted. [S1]
|
||||
- **Syntax (specific columns)** — `INSERT INTO target_table (column1, column2, ...) SELECT column1, column2, ... FROM source_table WHERE condition;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Partial-column copy leaves NULLs** — copying only some target columns (e.g. `CustomerName, City, Country`) leaves the unmapped target columns as NULL for the inserted rows. [S1]
|
||||
- **Filtered source-to-target copy** — a WHERE clause on the source SELECT restricts which rows get copied (e.g. only German suppliers). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Copy specific columns from Suppliers into Customers: `INSERT INTO Customers (CustomerName, City, Country) SELECT SupplierName, City, Country FROM Suppliers;`. [S1]
|
||||
- Copy all columns (requires matching schema): `INSERT INTO Customers SELECT * FROM Suppliers;`. [S1]
|
||||
- Copy a filtered subset: `INSERT INTO Customers (CustomerName, City, Country) SELECT SupplierName, City, Country FROM Suppliers WHERE Country='Germany';`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SELECT INTO(새 테이블 생성)와 대비되는, 기존 테이블 간 데이터 이관에 쓰이는 문서다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Copy filtered rows between existing tables (SQL):
|
||||
```sql
|
||||
INSERT INTO Customers (CustomerName, City, Country)
|
||||
SELECT SupplierName, City, Country FROM Suppliers
|
||||
WHERE Country='Germany';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select Into]], [[SQL Insert Into]], [[SQL Where]]
|
||||
- **참조 맥락:** 기존 테이블 간 데이터 이관 시 사용 — 새 테이블을 만들어야 한다면 대신 SELECT INTO를 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL INSERT INTO SELECT Statement — https://www.w3schools.com/sql/sql_insert_into_select.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL INSERT INTO SELECT Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: sql-intro
|
||||
title: "SQL Intro"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Introduction", "What is SQL", "SQL 소개", "Structured Query Language"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "rdbms", "basics"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SQL is the ANSI/ISO-standard language for accessing and manipulating data in a Relational Database Management System (RDBMS), where data lives in tables made of rows and columns. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL (Structured Query Language)** — a standard language for accessing and manipulating databases, standardized by ANSI (1986) and ISO (1987). [S1]
|
||||
- **What SQL can do** — execute queries, retrieve/insert/update/delete records, create databases/tables/stored procedures/views, and set permissions on tables, procedures, and views. [S1]
|
||||
- **Standard but fragmented** — although SQL is an ANSI/ISO standard, different database systems implement their own proprietary extensions on top of a common core (SELECT/UPDATE/DELETE/INSERT/WHERE). [S1]
|
||||
- **RDBMS (Relational Database Management System)** — the basis for SQL and all modern database systems (MS SQL Server, IBM DB2, Oracle, MySQL, MS Access); data is stored in tables, where a column is a vertical entity and a record (row) is a horizontal entity. [S1]
|
||||
- **Using SQL on a web site** — typically requires an RDBMS program (MS Access/SQL Server/MySQL), a server-side scripting language (PHP/ASP) to run SQL, and HTML/CSS to present the results. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Table = columns + rows** — every RDBMS models data as tables where columns define the schema and records (rows) hold the data. [S1]
|
||||
- **Standard-core + vendor-extension** — expect the major commands to work everywhere, but expect proprietary extensions to differ per vendor. [S1]
|
||||
- **Three-layer web stack** — RDBMS (data) + server-side language (logic) + HTML/CSS (presentation) is the classic pattern for a database-backed web site. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- SQL stands for **Structured Query Language** and lets you access and manipulate data stored in a database. [S1]
|
||||
- It became a standard of the American National Standards Institute (ANSI) in 1986 and of the International Organization for Standardization (ISO) in 1987. [S1]
|
||||
- Example table ("Customers") illustrates the RDBMS model:
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
- The Customers example table has columns `CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country`, and each row is one customer record. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 문서는 개론(Intro) 페이지로, 이후 SQL 튜토리얼 전체(SELECT/WHERE/JOIN 등)에서 여기서 정의한 RDBMS/테이블 모델이 반복 적용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Select all records from a table (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Syntax]], [[SQL Select]], [[SQL Create Table]]
|
||||
- **참조 맥락:** SQL 튜토리얼 전체의 진입점 — RDBMS/테이블 모델을 처음 정의하는 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Intro — https://www.w3schools.com/sql/sql_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Intro" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: sql-joins
|
||||
title: "SQL Joins"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL JOIN Clause", "SQL 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Joins]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
JOIN combines rows from two or more tables based on a related column between them, with four variants (INNER/LEFT/RIGHT/FULL) differing in which unmatched rows they keep. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **JOIN clause** — combines rows from two or more tables based on a related column. [S1]
|
||||
- **(INNER) JOIN** — returns only rows with matching values in both tables. [S1]
|
||||
- **LEFT (OUTER) JOIN** — returns all rows from the left table, plus matched rows from the right table. [S1]
|
||||
- **RIGHT (OUTER) JOIN** — returns all rows from the right table, plus matched rows from the left table. [S1]
|
||||
- **FULL (OUTER) JOIN** — returns all rows when there is a match in either table. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Related-column identification** — before writing a JOIN, identify the shared column between two tables (e.g. `CustomerID` appears in both "Orders" and "Customers"). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example relationship: the "Orders" table's `CustomerID` refers to the "Customers" table's `CustomerID`. [S1]
|
||||
- INNER JOIN combining the two: `SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;`. [S1]
|
||||
- The four JOIN types are summarized as covering: matches-only (INNER), left-preserving (LEFT), right-preserving (RIGHT), and both-preserving (FULL). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 문서는 개론이며, 각 JOIN 유형은 이어지는 개별 챕터(Inner/Left/Right/Full/Self Join)에서 상세히 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic INNER JOIN (SQL):
|
||||
```sql
|
||||
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
|
||||
FROM Orders
|
||||
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Inner Join]], [[SQL Left Join]], [[SQL Right Join]], [[SQL Full Join]], [[SQL Aliases]]
|
||||
- **참조 맥락:** JOIN 계열 챕터 전체의 개론 — 이후 4가지 JOIN 유형이 각각 별도 문서로 심화된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Joins — https://www.w3schools.com/sql/sql_join.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Joins" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: sql-left-join
|
||||
title: "SQL Left Join"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["LEFT JOIN", "LEFT OUTER JOIN", "SQL 왼쪽 외부 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join", "left-join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join_left.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Left Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
LEFT JOIN keeps every row from the left table regardless of a match, filling unmatched right-table columns with NULL — making it the tool for "find rows with no match" queries. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **LEFT JOIN** — returns all rows from the left table (table1), and only the matched rows from the right table (table2); unmatched right-side columns become NULL. [S1]
|
||||
- **LEFT JOIN == LEFT OUTER JOIN** — the `OUTER` keyword is optional and does not change behavior. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **NULL-filter for anti-join** — adding `WHERE Orders.CustomerID IS NULL` after a LEFT JOIN isolates rows from the left table that have NO match in the right table (e.g. customers who never placed an order) — a common "anti-join" pattern. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All customers with their orders, including customers with none: `SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID ORDER BY Customers.CustomerName;`. [S1]
|
||||
- Customers with NO orders (anti-join via NULL filter): `SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Orders.CustomerID IS NULL;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "주문 없는 고객 찾기" 패턴은 실무에서 흔한 리포팅 쿼리 형태다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
All rows from left table (SQL):
|
||||
```sql
|
||||
SELECT Customers.CustomerName, Orders.OrderID
|
||||
FROM Customers
|
||||
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
|
||||
ORDER BY Customers.CustomerName;
|
||||
```
|
||||
Anti-join: left rows with no right match (SQL):
|
||||
```sql
|
||||
SELECT Customers.CustomerName, Orders.OrderID
|
||||
FROM Customers
|
||||
LEFT JOIN Orders
|
||||
ON Customers.CustomerID = Orders.CustomerID
|
||||
WHERE Orders.CustomerID IS NULL;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Joins]], [[SQL Inner Join]], [[SQL Right Join]], [[SQL Null Values]]
|
||||
- **참조 맥락:** 왼쪽 테이블의 모든 행을 보존해야 하는 리포팅/anti-join 쿼리의 기본 도구.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL LEFT JOIN — https://www.w3schools.com/sql/sql_join_left.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL LEFT JOIN" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-like
|
||||
title: "SQL Like"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL LIKE Operator", "LIKE operator", "SQL 패턴 매칭"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "like", "pattern-matching", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_like.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Like]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
LIKE searches for a text pattern in a column using the `%` (any characters) and `_` (single character) wildcards, and can express starts-with/ends-with/contains matching. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **LIKE operator** — used in a WHERE clause to search for a specified pattern within a column's text data. [S1]
|
||||
- **Syntax** — `SELECT ... FROM table_name WHERE columnN LIKE pattern;`. [S1]
|
||||
- **`%` wildcard** — represents zero, one, or multiple characters. [S1]
|
||||
- **`_` wildcard** — represents exactly one character. [S1]
|
||||
- **No wildcard** — without a wildcard, LIKE requires an exact match. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Positional-% recipe** — `pattern%` = starts with, `%pattern` = ends with, `%pattern%` = contains, `pattern` (no `%`) = exact match. [S1]
|
||||
- **Combine with AND/OR** — multiple LIKE conditions can be combined, e.g. `CustomerName LIKE 'a%' OR CustomerName LIKE 'b%'`. [S1]
|
||||
- **Wildcard stacking** — `%` and `_` can be combined in one pattern, e.g. `'a__%'` (starts with "a", at least 3 chars) or `'_r%'` ("r" in second position). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Starts with: `WHERE CustomerName LIKE 'a%';`. [S1]
|
||||
- Contains: `WHERE city LIKE '%on%';`. [S1]
|
||||
- Single-character wildcard: `WHERE city LIKE 'l_nd__';` (l + 1 wildcard char + "nd" + 2 wildcard chars). [S1]
|
||||
- Ends with: `WHERE CustomerName LIKE '%a';`. [S1]
|
||||
- Starts-and-ends: `WHERE CustomerName LIKE 'b%s';`. [S1]
|
||||
- Exact match (no wildcard): `WHERE Country LIKE 'Spain';`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터인 SQL Wildcards에서 `[]`, `-`, `^` 같은 추가 와일드카드 문법이 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Starts-with / contains / ends-with (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers WHERE CustomerName LIKE 'a%'; -- starts with
|
||||
SELECT * FROM Customers WHERE city LIKE '%on%'; -- contains
|
||||
SELECT * FROM Customers WHERE CustomerName LIKE '%a'; -- ends with
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL Wildcards]], [[SQL Not]]
|
||||
- **참조 맥락:** 텍스트 패턴 매칭이 필요한 모든 검색 쿼리의 기반 문법 — 다음 챕터 Wildcards에서 문법이 확장된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL LIKE Operator — https://www.w3schools.com/sql/sql_like.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL LIKE Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: sql-max
|
||||
title: "SQL Max"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL MAX() Function", "MAX function", "SQL 최댓값"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "max", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_max.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Max]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
MAX() returns the largest value in a column across numeric, string, or date types, mirroring MIN() in syntax and usage. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **MAX() function** — returns the largest value of the selected column; works with numeric, string, and date data types. [S1]
|
||||
- **Syntax** — `SELECT MAX(column_name) FROM table_name WHERE condition;`. [S1]
|
||||
- **Unnamed result** — needs an `AS` alias to name the returned column. [S1]
|
||||
- **MAX() with GROUP BY** — returns the largest value per group. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Highest price: `SELECT MAX(Price) FROM Products;`. [S1]
|
||||
- With alias: `SELECT MAX(Price) AS HighestPrice FROM Products;`. [S1]
|
||||
- On a date column: `SELECT MAX(BirthDate) AS LatestBirthdate FROM Employees;`. [S1]
|
||||
- With GROUP BY: `SELECT MAX(Price) AS HighestPrice, CategoryID FROM Products GROUP BY CategoryID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — MIN()과 짝을 이뤄 범위(최소~최대) 리포트에 자주 함께 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
MAX with alias and GROUP BY (SQL):
|
||||
```sql
|
||||
SELECT MAX(Price) AS HighestPrice, CategoryID
|
||||
FROM Products
|
||||
GROUP BY CategoryID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Aggregate Functions]], [[SQL Min]], [[SQL Group By]]
|
||||
- **참조 맥락:** 최댓값 조회가 필요한 모든 리포트의 기본 함수 — MIN()과 대칭 관계.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL MAX() Function — https://www.w3schools.com/sql/sql_max.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL MAX() Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: sql-min
|
||||
title: "SQL Min"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL MIN() Function", "MIN function", "SQL 최솟값"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "min", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_min_max.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Min]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
MIN() returns the smallest value in a column across numeric, string, or date types, and its unnamed result column typically needs an alias. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **MIN() function** — returns the smallest value of the selected column; works with numeric, string, and date data types. [S1]
|
||||
- **Syntax** — `SELECT MIN(column_name) FROM table_name WHERE condition;`. [S1]
|
||||
- **Unnamed result** — MIN()'s returned column has no name by default; use `AS` to give it a descriptive alias. [S1]
|
||||
- **MIN() with GROUP BY** — returns the smallest value per group, e.g. lowest price per category. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Lowest price: `SELECT MIN(Price) FROM Products;`. [S1]
|
||||
- With alias: `SELECT MIN(Price) AS SmallestPrice FROM Products;`. [S1]
|
||||
- On a date column: `SELECT MIN(BirthDate) AS EarliestBirthdate FROM Employees;`. [S1]
|
||||
- With GROUP BY: `SELECT MIN(Price) AS SmallestPrice, CategoryID FROM Products GROUP BY CategoryID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — MAX()와 짝을 이뤄 범위(최소~최대) 리포트에 자주 함께 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
MIN with alias and GROUP BY (SQL):
|
||||
```sql
|
||||
SELECT MIN(Price) AS SmallestPrice, CategoryID
|
||||
FROM Products
|
||||
GROUP BY CategoryID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Aggregate Functions]], [[SQL Max]], [[SQL Group By]]
|
||||
- **참조 맥락:** 최솟값 조회가 필요한 모든 리포트의 기본 함수 — MAX()와 대칭 관계.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL MIN() Function — https://www.w3schools.com/sql/sql_min_max.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL MIN() Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-not
|
||||
title: "SQL Not"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL NOT Operator", "NOT operator", "SQL 부정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "not", "operators", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_not.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Not]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The NOT operator reverses a WHERE condition's truth value, and combines with LIKE, BETWEEN, IN, IS NULL, and comparison operators to express exclusion. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **NOT operator** — returns records that do NOT match the specified criteria, reversing a condition from true to false and vice versa. [S1]
|
||||
- **Syntax** — `SELECT ... FROM table_name WHERE NOT condition;`. [S1]
|
||||
- **Common NOT combinations** — `NOT LIKE`, `NOT BETWEEN`, `NOT IN`, `IS NOT NULL`, `NOT EXISTS`. [S1]
|
||||
- **NOT with comparisons** — "not greater than" and "not less than" are expressed as `WHERE NOT column > value` / `WHERE NOT column < value`, rather than dedicated operators. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Negate-by-wrapping** — rather than a distinct exclusion operator per case, SQL wraps `NOT` around an existing predicate (`=`, `LIKE`, `BETWEEN`, `IN`, comparison), giving a single uniform negation mechanism. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic negated equality: `SELECT * FROM Customers WHERE NOT Country = 'Spain';`. [S1]
|
||||
- NOT LIKE: `WHERE CustomerName NOT LIKE 'A%';` excludes names starting with "A". [S1]
|
||||
- NOT BETWEEN: `WHERE CustomerID NOT BETWEEN 10 AND 60;` selects rows outside the inclusive range. [S1]
|
||||
- NOT IN: `WHERE City NOT IN ('Paris', 'London');` excludes rows matching any listed value. [S1]
|
||||
- NOT with comparison: `WHERE NOT CustomerID > 50;` (not greater than) and `WHERE NOT CustomerId < 50;` (not less than). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — NOT은 LIKE/BETWEEN/IN 챕터 각각에서 반대 조건을 표현하는 공통 도구로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic NOT (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE NOT Country = 'Spain';
|
||||
```
|
||||
NOT combined with IN (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE City NOT IN ('Paris', 'London');
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL And]], [[SQL Or]], [[SQL Like]], [[SQL Between]], [[SQL In]]
|
||||
- **참조 맥락:** WHERE 절 조건을 반전시켜야 할 때 항상 재사용되는 범용 부정 연산자.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL NOT Operator — https://www.w3schools.com/sql/sql_not.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL NOT Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-not-null
|
||||
title: "SQL Not Null"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL NOT NULL Constraint", "NOT NULL constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "notnull", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_notnull.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Not Null]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
NOT NULL forces a column to always hold a value — columns are nullable by default — and can be added to or removed from an existing table via vendor-specific ALTER TABLE syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **NOT NULL constraint** — enforces a column to not accept NULL values; you cannot insert/update a record without a value for that field. [S1]
|
||||
- **Default is nullable** — columns accept NULL by default unless NOT NULL is specified. [S1]
|
||||
- **On CREATE TABLE** — add `NOT NULL` after the column's data type. [S1]
|
||||
- **On ALTER TABLE** — vendor-specific: SQL Server/MS Access use `ALTER COLUMN`, MySQL uses `MODIFY COLUMN`, Oracle 10G+ uses `MODIFY`. [S1]
|
||||
- **Removing NOT NULL** — same vendor-specific ALTER syntax, but specifying `NULL` instead of `NOT NULL`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- On table creation: `CREATE TABLE Persons (ID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, Age int);`. [S1]
|
||||
- Add NOT NULL after creation (SQL Server/Access): `ALTER TABLE Persons ALTER COLUMN Age int NOT NULL;`. [S1]
|
||||
- Add NOT NULL after creation (MySQL): `ALTER TABLE Persons MODIFY COLUMN Age int NOT NULL;`. [S1]
|
||||
- Remove NOT NULL (SQL Server/Access): `ALTER TABLE Persons ALTER COLUMN Age int NULL;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **벤더별 ALTER 문법 차이**: SQL Server/Access(`ALTER COLUMN`) vs. MySQL(`MODIFY COLUMN`) vs. Oracle(`MODIFY`)가 서로 다름. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — PRIMARY KEY의 구성 요소(UNIQUE + NOT NULL) 중 하나로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
NOT NULL on table creation (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255) NOT NULL,
|
||||
Age int
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Primary Key]], [[SQL Null Values]]
|
||||
- **참조 맥락:** 필수 입력 컬럼을 강제할 때 사용 — PRIMARY KEY 구성 요소 중 하나.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL NOT NULL Constraint — https://www.w3schools.com/sql/sql_notnull.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL NOT NULL Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: sql-null-functions
|
||||
title: "SQL Null Functions"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["COALESCE", "IFNULL", "ISNULL", "NVL", "SQL NULL 처리 함수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "null", "coalesce"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_isnull.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Null Functions]]
|
||||
|
||||
# 참고: 원문 제목은 "SQL NULL Functions"이며, w3schools 사이드바에는 "SQL Null Functions"로 표기됨
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every major SQL dialect has its own NULL-substitution function — COALESCE() is the portable standard, while IFNULL/ISNULL/NVL are vendor-specific equivalents — and a single NULL in an arithmetic expression silently NULLs the whole result unless substituted. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **The NULL-propagation problem** — an arithmetic expression involving a NULL value (e.g. `Price * (InStock + InOrder)` where `InOrder` is NULL) evaluates to NULL for that row. [S1]
|
||||
- **COALESCE()** — the preferred, portable standard; returns the first non-NULL value in a list; works in MySQL, SQL Server, and Oracle (not MS Access). [S1]
|
||||
- **IFNULL(expr, alt)** — MySQL-specific NULL substitution. [S1]
|
||||
- **ISNULL(expr, alt)** — SQL Server-specific NULL substitution. [S1]
|
||||
- **NVL(expr, alt)** — Oracle-specific NULL substitution. [S1]
|
||||
- **IsNull(expr) / IIf(expr, truepart, falsepart)** — MS Access's NULL-test-and-branch pair, used together to emulate substitution. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **One concept, five names** — "replace NULL with a default value" is implemented as five different vendor-specific functions, with COALESCE() the only one portable across MySQL/SQL Server/Oracle. [S1]
|
||||
- **MS Access needs two functions** — unlike the other vendors' single substitution function, MS Access requires composing `IsNull()` (test) with `IIf()` (branch) to achieve the same effect. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **COALESCE()** | MySQL/SQL Server/Oracle에서 이식 가능, 표준에 가까움 | MS Access 미지원 | 여러 DB를 오갈 가능성이 있는 코드 |
|
||||
| **IFNULL/ISNULL/NVL** | 해당 벤더에서 짧고 관용적 | 다른 DB로 이식 불가 | 특정 벤더 전용 코드베이스 |
|
||||
| **MS Access IsNull()+IIf()** | Access 네이티브 방식 | 두 함수 조합이 필요해 장황함 | MS Access 전용 쿼리 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- NULL propagation problem: `SELECT ProductName, Price * (InStock + InOrder) FROM Products;` — returns NULL for any row where `InOrder` is NULL. [S1]
|
||||
- COALESCE fix: `SELECT ProductName, Price * (InStock + COALESCE(InOrder, 0)) FROM Products;`. [S1]
|
||||
- MySQL: `SELECT ProductName, Price * (InStock + IFNULL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- SQL Server: `SELECT ProductName, Price * (InStock + ISNULL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- Oracle: `SELECT ProductName, Price * (InStock + NVL(InOrder, 0)) FROM Products;`. [S1]
|
||||
- MS Access: `SELECT ProductName, Price * (InStock + IIf(IsNull(InOrder), 0, InOrder)) FROM Products;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **벤더별 함수명 불일치가 핵심 메시지**: 동일한 의도가 COALESCE/IFNULL/ISNULL/NVL/IsNull+IIf로 벤더마다 다르게 구현됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 재고 계산처럼 산술식에 NULL이 섞일 수 있는 모든 계산 쿼리에서 재사용되는 방어적 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Portable NULL substitution (SQL, COALESCE):
|
||||
```sql
|
||||
SELECT ProductName, Price * (InStock + COALESCE(InOrder, 0))
|
||||
FROM Products;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Null Values]], [[SQL Case]]
|
||||
- **참조 맥락:** 산술식·집계에 NULL이 섞여 결과가 오염되는 것을 막을 때 사용 — 이식성이 필요하면 COALESCE()를 우선 고려.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL NULL Functions — https://www.w3schools.com/sql/sql_isnull.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL NULL Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: sql-null-values
|
||||
title: "SQL Null Values"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["NULL values", "IS NULL", "IS NOT NULL", "SQL 널 값"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "null"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_null_values.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Null Values]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
NULL represents an unknown or absent value — distinct from zero or an empty string — and can only be tested with IS NULL / IS NOT NULL, never with `=`, `<`, or `<>`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **NULL value** — represents unknown, missing, or inapplicable data; a placeholder for absence of data, not a value itself. [S1]
|
||||
- **NULL ≠ 0 or ''** — a NULL field is one left blank at record creation, distinct from zero or an empty string. [S1]
|
||||
- **Comparison operators don't work on NULL** — `=`, `<`, `<>` cannot test for NULL; use `IS NULL` / `IS NOT NULL` instead. [S1]
|
||||
- **Syntax** — `SELECT column_names FROM table_name WHERE column_name IS NULL;` and the `IS NOT NULL` counterpart. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Dedicated NULL-test operators** — because ordinary comparison operators silently fail to match NULL, SQL provides `IS NULL`/`IS NOT NULL` as the only reliable test — a common footgun for beginners who try `WHERE column = NULL`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Find rows with a NULL field: `SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NULL;`. [S1]
|
||||
- Find rows with a non-NULL field: `SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NOT NULL;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — LEFT JOIN의 anti-join 패턴(`WHERE Orders.CustomerID IS NULL`)에서 이미 이 문법이 선행 사용되었다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Test for NULL / NOT NULL (SQL):
|
||||
```sql
|
||||
SELECT CustomerName, ContactName, Address
|
||||
FROM Customers
|
||||
WHERE Address IS NULL;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL Left Join]], [[SQL Null Functions]]
|
||||
- **참조 맥락:** NULL을 다뤄야 하는 모든 쿼리의 기초 — 이후 SQL Null Functions(COALESCE 등)에서 NULL 대체 함수로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL NULL Values — https://www.w3schools.com/sql/sql_null_values.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL NULL Values" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: sql-operators
|
||||
title: "SQL Operators"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL operator reference", "SQL 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_operators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SQL operators split into five families — arithmetic, comparison, compound, bitwise, and logical — with the logical family (AND/OR/IN/LIKE/BETWEEN/EXISTS/ANY/ALL/SOME) being the set that composes WHERE-clause conditions. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL operators** — keywords and symbols used to perform operations with data values, used in statements like SELECT, WHERE, LIKE. [S1]
|
||||
- **Five categories** — Arithmetic, Comparison, Compound, Bitwise, Logical. [S1]
|
||||
- **Arithmetic operators** — `+`, `-`, `*`, `/`, `%` (modulus). [S1]
|
||||
- **Comparison operators** — `=`, `>`, `<`, `>=`, `<=`, `<>`. [S1]
|
||||
- **Compound operators** — `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `^=`, `|*=` (assignment-with-operation shorthands). [S1]
|
||||
- **Bitwise operators** — `&`, `|`, `^`, `~`. [S1]
|
||||
- **Logical operators** — `ALL`, `AND`, `ANY`, `BETWEEN`, `EXISTS`, `IN`, `LIKE`, `NOT`, `OR`, `SOME`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Logical operators as the WHERE-clause vocabulary** — nearly every operator covered in this tutorial's earlier WHERE/filtering chapters (AND, OR, NOT, IN, BETWEEN, LIKE, EXISTS, ANY, ALL) is consolidated here as one "logical operators" family, plus `SOME` as an ANY synonym not covered elsewhere in the tutorial. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 산술/비교/복합대입/비트/논리 다섯 범주의 연산자 기호표를 요약 제공하는 레퍼런스 성격의 챕터다. 개별 논리 연산자(AND/OR/IN/LIKE/BETWEEN/EXISTS/ANY/ALL)의 상세 문법과 예제는 각각의 전용 챕터에서 이미 다뤄졌다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **`SOME`** 연산자는 "ANY의 어떤 서브쿼리 값이든 조건을 만족하면 TRUE"로 ANY와 동일한 의미로 소개되지만, 튜토리얼의 다른 어느 챕터에서도 SOME 전용 챕터는 없음 — ANY의 동의어로만 언급됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 문서는 앞선 WHERE/필터링 챕터들에서 다룬 논리 연산자를 하나의 기호표로 정리한 레퍼런스다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (연산자 기호와 설명 위주의 레퍼런스 표).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL And]], [[SQL Or]], [[SQL In]], [[SQL Like]], [[SQL Between]], [[SQL Exists]], [[SQL Any]], [[SQL All]]
|
||||
- **참조 맥락:** 앞서 배운 논리 연산자들을 한눈에 정리한 요약 레퍼런스 — 처음 학습보다는 빠른 조회용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Operators — https://www.w3schools.com/sql/sql_operators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: sql-or
|
||||
title: "SQL Or"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL OR Operator", "OR operator", "SQL 논리합"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "or", "operators", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_or.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Or]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The OR operator filters records so that a row is returned if ANY of the chained conditions in the WHERE clause is true. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **OR operator** — combines multiple conditions in a WHERE clause; a record is returned if at least one condition is TRUE. [S1]
|
||||
- **Syntax** — `SELECT ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...;`. [S1]
|
||||
- **AND vs. OR** — OR requires only one condition true, whereas AND requires all conditions true. [S1]
|
||||
- **Combining AND and OR** — mixing the two requires parentheses to control evaluation grouping. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Multi-condition OR chain** — three or more OR'd conditions (`City = 'Berlin' OR CustomerName LIKE 'G%' OR Country = 'Norway'`) generalize cleanly beyond a simple two-value check. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Filter on two alternative values: `SELECT * FROM Customers WHERE Country = 'Germany' OR Country = 'Spain';`. [S1]
|
||||
- Filter on three OR'd conditions: `WHERE City = 'Berlin' OR CustomerName LIKE 'G%' OR Country = 'Norway';`. [S1]
|
||||
- Mixed AND/OR needs parentheses for the intended grouping (see [[SQL And]] for the worked example). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL IN 연산자가 동일 컬럼에 대한 다중 OR 조건의 축약형으로 이후 챕터에서 소개된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
OR across two values (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Germany' OR Country = 'Spain';
|
||||
```
|
||||
OR across three conditions (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE City = 'Berlin' OR CustomerName LIKE 'G%' OR Country = 'Norway';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL And]], [[SQL In]]
|
||||
- **참조 맥락:** WHERE 절 다중 조건 결합의 기본 연산자 — AND/NOT과 세트로 이해해야 하며, IN 연산자로 축약 가능.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL OR Operator — https://www.w3schools.com/sql/sql_or.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL OR Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: sql-order-by
|
||||
title: "SQL Order By"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL ORDER BY Keyword", "ORDER BY clause", "SQL 정렬"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "orderby", "sorting"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_orderby.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Order By]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
ORDER BY sorts a result-set by one or more columns, ascending by default, and can mix ascending/descending direction per column. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **ORDER BY keyword** — sorts the result-set in ascending (ASC, default) or descending (DESC) order. [S1]
|
||||
- **Syntax** — `SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC;`. [S1]
|
||||
- **Alphabetical sorting** — for text columns, ORDER BY sorts alphabetically (and reverse-alphabetically with DESC). [S1]
|
||||
- **Multi-column sort** — sorting by several columns applies the first column as primary sort key and subsequent columns as tie-breakers. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Per-column direction** — each column in a multi-column ORDER BY can independently specify ASC or DESC, e.g. `ORDER BY Country ASC, CustomerName DESC`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Sort ascending by default: `SELECT * FROM Products ORDER BY Price;`. [S1]
|
||||
- Sort descending: `SELECT * FROM Products ORDER BY Price DESC;`. [S1]
|
||||
- Sort multiple columns, Country first then CustomerName as tie-break: `SELECT * FROM Customers ORDER BY Country, CustomerName;`. [S1]
|
||||
- Combine directions per column: `SELECT * FROM Customers ORDER BY Country ASC, CustomerName DESC;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 정렬은 이후 JOIN/GROUP BY 결과를 사람이 읽기 좋게 만드는 데 반복적으로 함께 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Sort ascending (default) then descending (SQL):
|
||||
```sql
|
||||
SELECT * FROM Products ORDER BY Price;
|
||||
SELECT * FROM Products ORDER BY Price DESC;
|
||||
```
|
||||
Multi-column sort with mixed direction (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
ORDER BY Country ASC, CustomerName DESC;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL Where]], [[SQL Group By]]
|
||||
- **참조 맥락:** 조회 결과를 정렬해서 보여줘야 하는 모든 쿼리에서 재사용되는 기본 문법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL ORDER BY Keyword — https://www.w3schools.com/sql/sql_orderby.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL ORDER BY Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-parameters
|
||||
title: "SQL Parameters"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Parameterized Queries", "SQL 파라미터화 쿼리"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "security", "parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_parameterized_queries.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Parameters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Parameterized queries fix SQL injection by sending user input as placeholder-bound values instead of concatenated text, so the database always treats the input literally, never as executable SQL. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Parameterized query** — an SQL statement using placeholders instead of directly embedding input values in the query text; placeholders are replaced with actual values at execution time. [S1]
|
||||
- **Placeholder syntax varies by vendor** — MySQL uses `?`, SQL Server uses `@`, PostgreSQL uses `$`. [S1]
|
||||
- **Literal treatment guarantee** — the SQL engine checks each parameter against its column type and treats it literally, not as part of the executable SQL — this is what neutralizes injection. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Same fix for SELECT and INSERT** — the parameterization pattern applies identically whether reading (`SELECT ... WHERE UserId = @userid`) or writing (`INSERT INTO ... VALUES(@cname, @caddress, @ccity)`). [S1]
|
||||
- **Bind-then-execute in application code** — frameworks like ASP.NET separate building the query text (with placeholders) from binding actual values (`cmd.Parameters.AddWithValue(...)`), directly countering the string-concatenation root cause from [[SQL Injection]]. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- SQL Server-style placeholder query: `query = "SELECT * FROM Users WHERE UserId = @userid"; db.Execute(query, userid);`. [S1]
|
||||
- Parameterized INSERT: `query = "INSERT INTO Customers (CustomerName, Address, City) Values(@cname, @caddress, @ccity)"; db.Execute(query, cname, caddress, ccity);`. [S1]
|
||||
- ASP.NET binding pattern: `cmd = new SqlCommand(query); cmd.Parameters.AddWithValue("@userid", userid); cmd.ExecuteReader();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 앞서 SQL Injection 챕터에서 보여준 문자열 연결(concatenation) 취약점을 직접 해소하는 대응책이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parameterized SELECT (ASP.NET, SQL Server style):
|
||||
```
|
||||
userid = getRequestString("UserId");
|
||||
query = "SELECT * FROM Customers WHERE CustomerId = @userid";
|
||||
cmd = new SqlCommand(query);
|
||||
cmd.Parameters.AddWithValue("@userid", userid);
|
||||
cmd.ExecuteReader();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Injection]], [[SQL Prepared Statements]]
|
||||
- **참조 맥락:** SQL Injection의 직접적인 대응책 — Prepared Statements와 함께 사용자 입력을 다루는 표준 방어법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Parameters — https://www.w3schools.com/sql/sql_parameterized_queries.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: sql-prepared-statements
|
||||
title: "SQL Prepared Statements"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Prepared Statements", "SQL 준비된 문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "security", "prepared-statements", "php", "mysql"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_prepared_statements.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Prepared Statements]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Prepared statements separate a query's structure (compiled once, sent as a placeholder template) from its data (bound and sent later, possibly many times) — gaining security, performance, and bandwidth savings in one mechanism. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Prepared statement** — separates the query structure (the SQL) from the actual data (user input). [S1]
|
||||
- **Two-phase lifecycle** — Prepare (send a placeholder template like `INSERT INTO MyGuests VALUES(?, ?, ?)`, parsed/compiled/optimized without executing) then Execute (bind values, run — repeatable with different values). [S1]
|
||||
- **Four advantages** — reduced parsing time (prepared once, executed many times), minimized bandwidth (only parameters sent per call, not the whole query), security (bound values need not be escaped and can't alter the SQL structure), cleaner code (data separated from SQL). [S1]
|
||||
- **Type-tagged binding (MySQL)** — `bind_param("sss", ...)` declares each parameter's type (`i`=integer, `d`=double, `s`=string, `b`=binary), which minimizes injection risk by telling MySQL exactly what type to expect. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Prepare-once, execute-many** — a single prepared statement can be executed repeatedly with different bound values (three inserts in the example, same statement object). [S1]
|
||||
- **Sanitize inputs from external sources anyway** — the source notes that even with prepared statements, data from user input should still be sanitized/validated — prepared statements prevent structural injection, not all bad input. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQL prepared statement (PHP), templated insert with three placeholders: [S1]
|
||||
```php
|
||||
$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)";
|
||||
if($stmt = $conn->prepare($sql)) {
|
||||
$stmt->bind_param("sss", $firstname, $lastname, $email);
|
||||
$firstname = "John"; $lastname = "Doe"; $email = "john@example.com";
|
||||
$stmt->execute();
|
||||
// ... repeat with different values, same $stmt
|
||||
}
|
||||
```
|
||||
- Type characters for `bind_param`: `i` integer, `d` double, `s` string, `b` binary. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Parameters(단순 바인딩)와 함께 SQL Injection 방어의 양대 축을 이룬다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Prepared statement, prepare once execute many (PHP/MySQL):
|
||||
```php
|
||||
$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("sss", $firstname, $lastname, $email);
|
||||
$stmt->execute();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Injection]], [[SQL Parameters]], [[SQL Stored Procedures]]
|
||||
- **참조 맥락:** SQL Injection 방어와 반복 실행 성능 최적화를 동시에 달성하는 표준 기법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Prepared Statements — https://www.w3schools.com/sql/sql_prepared_statements.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Prepared Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-primary-key
|
||||
title: "SQL Primary Key"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL PRIMARY KEY Constraint", "PRIMARY KEY constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "primarykey", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_primarykey.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Primary Key]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PRIMARY KEY uniquely identifies every row (as a UNIQUE + NOT NULL combination), can span multiple columns, and is the anchor that FOREIGN KEY constraints in other tables point to. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **PRIMARY KEY constraint** — uniquely identifies each record; ensures unique values and cannot contain NULL (combination of UNIQUE + NOT NULL). [S1]
|
||||
- **One per table** — a table can have only ONE PRIMARY KEY, which can be a single column or a combination of columns (composite key). [S1]
|
||||
- **FK anchor** — the primary key is the target that FOREIGN KEY constraints in other tables reference, enforcing referential integrity. [S1]
|
||||
- **ALTER TABLE prerequisite** — adding a PRIMARY KEY via ALTER TABLE requires the column(s) already be declared NOT NULL. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single-column PK on creation: `CREATE TABLE Persons (ID int PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Age int);`. [S1]
|
||||
- Composite (multi-column) PK: `PRIMARY KEY (ID, LastName)`, or named: `CONSTRAINT PK_Person PRIMARY KEY (ID, LastName)`. [S1]
|
||||
- Add PK to existing table: `ALTER TABLE Persons ADD PRIMARY KEY (ID);`. [S1]
|
||||
- Drop PK: `ALTER TABLE Persons DROP CONSTRAINT PK_Person;` (SQL Server/Oracle/Access) vs. `ALTER TABLE Persons DROP PRIMARY KEY;` (MySQL). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **드롭 문법 차이**: SQL Server/Oracle/Access는 `DROP CONSTRAINT`, MySQL은 `DROP PRIMARY KEY`를 사용. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — FOREIGN KEY 챕터에서 이 PRIMARY KEY를 참조하는 관계가 바로 이어서 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Composite primary key (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int,
|
||||
LastName varchar(255),
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
CONSTRAINT PK_Person PRIMARY KEY (ID, LastName)
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Foreign Key]], [[SQL Not Null]], [[SQL Unique]], [[SQL Auto Increment]]
|
||||
- **참조 맥락:** 테이블 설계의 핵심 — FOREIGN KEY가 참조하는 대상이자, 대개 AUTO INCREMENT와 함께 쓰인다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL PRIMARY KEY Constraint — https://www.w3schools.com/sql/sql_primarykey.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL PRIMARY KEY Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: sql-right-join
|
||||
title: "SQL Right Join"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["RIGHT JOIN", "RIGHT OUTER JOIN", "SQL 오른쪽 외부 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join", "right-join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join_right.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Right Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
RIGHT JOIN is LEFT JOIN with the table roles mirrored — it keeps every row from the right table regardless of a match, filling unmatched left-table columns with NULL. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **RIGHT JOIN** — returns all rows from the right table (table2), and only the matched rows from the left table (table1); unmatched left-side columns become NULL. [S1]
|
||||
- **RIGHT JOIN == RIGHT OUTER JOIN** — the `OUTER` keyword is optional. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **LEFT/RIGHT symmetry** — a RIGHT JOIN can always be rewritten as a LEFT JOIN by swapping which table is written first; teams often standardize on LEFT JOIN alone for consistency (implied by RIGHT JOIN's comparative rarity in practice, though not stated verbatim in the source). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All employees and any orders they placed (employees preserved even with zero orders): `SELECT Orders.OrderID, Employees.LastName, Employees.FirstName FROM Orders RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID ORDER BY Orders.OrderID;`. [S1]
|
||||
- The RIGHT JOIN keyword returns all records from the right table (Employees), even where there is no match in the left table (Orders). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "직원별 주문 실적(0건 포함)" 같은 리포트에서 전형적으로 쓰이는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
All rows from right table (SQL):
|
||||
```sql
|
||||
SELECT Orders.OrderID, Employees.LastName, Employees.FirstName
|
||||
FROM Orders
|
||||
RIGHT JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
|
||||
ORDER BY Orders.OrderID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Joins]], [[SQL Left Join]], [[SQL Full Join]]
|
||||
- **참조 맥락:** LEFT JOIN의 대칭 개념 — 오른쪽 테이블의 모든 행을 보존해야 할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL RIGHT JOIN — https://www.w3schools.com/sql/sql_join_right.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL RIGHT JOIN" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: sql-select
|
||||
title: "SQL Select"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SELECT Statement", "SELECT statement", "SQL 조회"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.92
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "select", "query"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_select.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Select]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The SELECT statement retrieves data from a database — name specific columns to select a subset, or use `*` to select every column of a table. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SELECT statement** — used to select data from a database; the result is stored in a result table (the "result-set"). [S1]
|
||||
- **SELECT syntax** — `SELECT column1, column2, ... FROM table_name;` where `column1, column2, ...` are the columns to retrieve and `table_name` is the source table. [S1]
|
||||
- **SELECT \*** — selects ALL columns of a table without naming each one individually. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Explicit column list vs. wildcard** — naming exact columns (`SELECT CustomerName, City FROM Customers;`) is more precise and efficient than `SELECT * FROM Customers;`, which returns every column. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **컬럼 명시 (`SELECT col1, col2`)** | 필요한 데이터만 가져와 트래픽/처리 비용 절감, 의도가 명확함 | 컬럼이 추가/변경될 때 쿼리를 수정해야 함 | 프로덕션 쿼리, 필요한 컬럼이 명확할 때 |
|
||||
| **와일드카드 (`SELECT *`)** | 작성이 빠르고 모든 컬럼을 즉시 확인 가능 | 불필요한 데이터 전송, 테이블 구조 변경에 취약 | 탐색적 조회, 임시 디버깅 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Return specific columns from the Customers table: [S1]
|
||||
```sql
|
||||
SELECT CustomerName, City FROM Customers;
|
||||
```
|
||||
- Select every column from the Customers table: [S1]
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
- The demo Customers table used throughout the tutorial has columns `CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SELECT 문은 이후 WHERE/ORDER BY/JOIN 등 거의 모든 SQL 튜토리얼 챕터의 기반 문법으로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Select specific columns (SQL):
|
||||
```sql
|
||||
SELECT CustomerName, City FROM Customers;
|
||||
```
|
||||
Select all columns (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.92
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Syntax]], [[SQL Where]], [[SQL Select Distinct]], [[SQL Order By]]
|
||||
- **참조 맥락:** 데이터 조회의 가장 기본이 되는 문서 — WHERE/JOIN/GROUP BY 등 이후 모든 조회 관련 챕터의 출발점.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SELECT Statement — https://www.w3schools.com/sql/sql_select.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SELECT Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-select-distinct
|
||||
title: "SQL Select Distinct"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SELECT DISTINCT Statement", "DISTINCT keyword", "SQL 중복 제거"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "distinct", "select"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_distinct.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Select Distinct]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SELECT DISTINCT returns only unique values from a column, collapsing duplicate rows that a plain SELECT would otherwise repeat. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SELECT DISTINCT** — returns only distinct (unique) values, removing duplicate rows from the result. [S1]
|
||||
- **Syntax** — `SELECT DISTINCT column1, column2, ... FROM table_name;`. [S1]
|
||||
- **COUNT(DISTINCT column)** — counts the number of unique values in a column, but is not supported in Microsoft Access. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Dedup-then-count workaround** — for databases lacking `COUNT(DISTINCT ...)` (e.g. MS Access), wrap a `SELECT DISTINCT` subquery and `COUNT(*)` the outer result: `SELECT Count(*) AS DistinctCountries FROM (SELECT DISTINCT Country FROM Customers);`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Without DISTINCT, a query returns the column's value from every record, including repeats: `SELECT Country FROM Customers;`. [S1]
|
||||
- With DISTINCT, only unique values are returned: `SELECT DISTINCT Country FROM Customers;`. [S1]
|
||||
- Counting unique values directly: `SELECT COUNT(DISTINCT Country) FROM Customers;` — not supported on MS Access, which needs the subquery workaround above. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **DBMS 차이**: `COUNT(DISTINCT column_name)`이 MS Access에서는 지원되지 않는다는 점이 명시적으로 언급됨 — 방언별 차이가 존재. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 COUNT() 챕터에서 DISTINCT와의 조합이 더 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Select unique values (SQL):
|
||||
```sql
|
||||
SELECT DISTINCT Country FROM Customers;
|
||||
```
|
||||
Count unique values, MS Access-safe (SQL):
|
||||
```sql
|
||||
SELECT Count(*) AS DistinctCountries
|
||||
FROM (SELECT DISTINCT Country FROM Customers);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL Count]], [[SQL Group By]]
|
||||
- **참조 맥락:** SELECT 결과의 중복을 제거해야 할 때 참조하는 문서 — COUNT()와 결합해 고유값 개수를 셀 때 자주 함께 쓰인다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SELECT DISTINCT Statement — https://www.w3schools.com/sql/sql_distinct.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SELECT DISTINCT Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: sql-select-into
|
||||
title: "SQL Select Into"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SELECT INTO Statement", "SELECT INTO", "SQL 테이블 복사"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "selectinto", "backup"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_select_into.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Select Into]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SELECT INTO creates a brand-new table populated from an existing one — useful for backups or ad-hoc analysis tables — but does not carry over primary keys, indexes, or NOT NULL constraints. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SELECT INTO statement** — creates a new table and fills it with data from an existing table. [S1]
|
||||
- **Constraint loss** — the new table gets the same column names/types as the source, but NOT primary keys, indexes, or NOT NULL constraints. [S1]
|
||||
- **Syntax (full copy)** — `SELECT * INTO newtable [IN external_db] FROM sourcetable WHERE condition;`. [S1]
|
||||
- **Syntax (partial copy)** — `SELECT column1, column2, ... INTO newtable [IN external_db] FROM sourcetable WHERE condition;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Empty-schema-clone trick** — `SELECT * INTO newtable FROM sourcetable WHERE 1 = 0;` creates a new, empty table with the source's schema, by using a condition that structurally can never be true. [S1]
|
||||
- **Multi-table copy** — SELECT INTO can source from a JOIN across multiple tables, not just a single table. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full backup copy: `SELECT * INTO CustomersBackup2026 FROM Customers;`. [S1]
|
||||
- Backup into another database: `SELECT * INTO CustomersBackup2026 IN 'Backup.mdb' FROM Customers;`. [S1]
|
||||
- Copy specific columns only: `SELECT CustomerName, ContactName INTO Customers2 FROM Customers;`. [S1]
|
||||
- Copy a filtered subset: `SELECT * INTO US_Customers FROM Customers WHERE Country = 'USA';`. [S1]
|
||||
- Copy from a JOIN: `SELECT Customers.CustomerName, Orders.OrderID INTO CustomersOrder FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;`. [S1]
|
||||
- Empty schema-only clone: `SELECT * INTO newtable FROM sourcetable WHERE 1 = 0;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 새 테이블이 원본의 제약조건(PK/인덱스/NOT NULL)을 물려받지 않는다는 한계가 명시적으로 언급됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 백업 테이블 생성, 분석용 임시 테이블 생성에 전형적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Backup copy of a table (SQL):
|
||||
```sql
|
||||
SELECT * INTO CustomersBackup2026
|
||||
FROM Customers;
|
||||
```
|
||||
Schema-only empty clone (SQL):
|
||||
```sql
|
||||
SELECT * INTO newtable
|
||||
FROM sourcetable
|
||||
WHERE 1 = 0;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Insert Into Select]], [[SQL Create Table]], [[SQL Left Join]]
|
||||
- **참조 맥락:** 새 테이블을 만들며 데이터를 채워야 할 때 사용 — 기존 테이블에 데이터만 옮기려면 대신 INSERT INTO SELECT를 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SELECT INTO Statement — https://www.w3schools.com/sql/sql_select_into.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SELECT INTO Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: sql-select-top
|
||||
title: "SQL Select Top"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SELECT TOP", "LIMIT", "FETCH FIRST", "SQL 상위 N개 조회"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "top", "limit", "fetchfirst"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_top.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Select Top]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Limiting the number of returned rows uses a different keyword per vendor — TOP (SQL Server/MS Access), LIMIT (MySQL), or FETCH FIRST (Oracle) — with no single standard syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SELECT TOP clause** — limits the number of records returned; useful on large tables to avoid the performance cost of returning huge result sets. [S1]
|
||||
- **Vendor fragmentation** — SQL Server/MS Access use `TOP`, MySQL uses `LIMIT`, Oracle 12+ uses `FETCH FIRST n ROWS ONLY`. [S1]
|
||||
- **TOP PERCENT** — SQL Server/MS Access can limit by percentage of rows instead of a fixed count. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Always pair with ORDER BY for determinism** — without an explicit sort, "the first N rows" is not well-defined; ORDER BY makes a TOP/LIMIT/FETCH FIRST query reproducible. [S1]
|
||||
- **Row-limiting composes with WHERE** — vendor-specific limit syntax combines normally with WHERE filters. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **TOP (SQL Server/Access)** | 컬럼 목록 앞에 붙여 간단 | 다른 DB로 이식 불가 | SQL Server/MS Access 전용 쿼리 |
|
||||
| **LIMIT (MySQL)** | 쿼리 끝에 붙여 직관적 | 표준 SQL이 아님, 벤더 종속 | MySQL/PostgreSQL 계열 |
|
||||
| **FETCH FIRST (Oracle 12+)** | ANSI SQL:2008 표준에 가까움 | Oracle 12 이전 버전 미지원 | Oracle 최신 버전 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- SQL Server/MS Access: `SELECT TOP 3 * FROM Customers;`. [S1]
|
||||
- MySQL: `SELECT * FROM Customers LIMIT 3;`. [S1]
|
||||
- Oracle 12+: `SELECT * FROM Customers FETCH FIRST 3 ROWS ONLY;`. [S1]
|
||||
- Percent-based limit (SQL Server/Access): `SELECT TOP 50 PERCENT * FROM Customers;`. [S1]
|
||||
- Combined with WHERE and ORDER BY (SQL Server/Access): `SELECT TOP 3 * FROM Customers ORDER BY CustomerName DESC;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **표준 부재가 핵심 메시지**: "상위 N개 행" 요청 자체에 대한 SQL 표준 문법이 존재하지 않으며, 세 개 주요 벤더가 서로 다른 키워드를 사용한다는 점이 소스의 명시적 경고. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대용량 테이블에서 성능을 위해 결과 행 수를 제한하는 것은 실무에서 매우 흔한 요구사항이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Same "top 3" query per vendor (SQL):
|
||||
```sql
|
||||
-- SQL Server / MS Access
|
||||
SELECT TOP 3 * FROM Customers;
|
||||
-- MySQL
|
||||
SELECT * FROM Customers LIMIT 3;
|
||||
-- Oracle 12+
|
||||
SELECT * FROM Customers FETCH FIRST 3 ROWS ONLY;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Order By]], [[SQL Where]]
|
||||
- **참조 맥락:** 대용량 테이블에서 결과 행 수를 제한해야 할 때 참조 — 사용 중인 DB 벤더에 맞는 문법을 먼저 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SELECT TOP, LIMIT and FETCH FIRST — https://www.w3schools.com/sql/sql_top.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SELECT TOP, LIMIT and FETCH FIRST" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-self-join
|
||||
title: "SQL Self Join"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Self Join", "SQL 자기 조인"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "join", "self-join"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_join_self.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Self Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A self join is a regular join where a table is joined with itself, made possible by giving the same table two different aliases so rows can be compared against other rows in the same table. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Self join** — a regular join where the table is joined with itself. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 T1, table1 T2 WHERE condition;` where T1 and T2 are different aliases for the same table. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Exclude self-match** — a self join typically needs a condition like `A.CustomerID <> B.CustomerID` to avoid matching each row with itself. [S1]
|
||||
- **Dual-alias comparison** — the same table appears twice with different aliases (A, B) purely so SQL can treat the two references as independent row sets for comparison. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Match customers that share the same city (excluding matching a customer with itself): [S1]
|
||||
```sql
|
||||
SELECT A.CustomerName AS CustomerName1, B.CustomerName AS CustomerName2, A.City
|
||||
FROM Customers A, Customers B
|
||||
WHERE A.CustomerID <> B.CustomerID
|
||||
AND A.City = B.City
|
||||
ORDER BY A.City;
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 조직도(상사-부하 관계), 동일 도시 고객 찾기 등 "같은 테이블 내 행 간 관계"를 표현할 때 쓰이는 전형적 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Self join with alias and self-match exclusion (SQL):
|
||||
```sql
|
||||
SELECT A.CustomerName AS CustomerName1, B.CustomerName AS CustomerName2, A.City
|
||||
FROM Customers A, Customers B
|
||||
WHERE A.CustomerID <> B.CustomerID
|
||||
AND A.City = B.City
|
||||
ORDER BY A.City;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Joins]], [[SQL Aliases]], [[SQL Inner Join]]
|
||||
- **참조 맥락:** 같은 테이블 내 행 간 관계를 표현해야 할 때(계층 구조, 동일 그룹 찾기) 재사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Self Join — https://www.w3schools.com/sql/sql_join_self.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Self Join" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,100 @@
|
||||
---
|
||||
id: sql-stored-procedures
|
||||
title: "SQL Stored Procedures"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Stored Procedure", "CREATE PROCEDURE", "SQL 저장 프로시저"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "stored-procedure"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_stored_procedures.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Stored Procedures]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A stored procedure is precompiled, reusable, parameterized SQL saved in the database — trading a bit of upfront setup for reuse, performance, security, and centralized maintenance. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Stored procedure** — precompiled SQL code that can be saved and reused; can accept parameters to vary its behavior per call. [S1]
|
||||
- **Key benefits** — code reusability (callable from various applications), improved performance (precompiled), database security (permission can be scoped to the procedure rather than direct table access), easy maintenance (one update propagates to all callers). [S1]
|
||||
- **Create syntax (SQL Server)** — `CREATE PROCEDURE procedure_name @param1 datatype, @param2 datatype AS BEGIN ... END;`. [S1]
|
||||
- **Execute syntax** — `EXEC procedure_name @param1 = 'value1', @param2 = 'value2';`. [S1]
|
||||
- **Drop syntax** — `DROP PROCEDURE procedure_name;`, or safely with `DROP PROCEDURE IF EXISTS procedure_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Security-through-indirection** — granting users permission to execute a specific procedure (rather than direct table access) limits what they can do while still letting them accomplish their task. [S1]
|
||||
- **Idempotent drop** — `IF EXISTS` on DROP PROCEDURE avoids an error if the procedure was already removed, useful in re-runnable setup/migration scripts. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single-parameter procedure: [S1]
|
||||
```sql
|
||||
CREATE PROCEDURE GetCustomersByCity
|
||||
@City nvarchar(50)
|
||||
AS
|
||||
BEGIN
|
||||
SELECT * FROM Customers
|
||||
WHERE City = @City;
|
||||
END;
|
||||
```
|
||||
Executed with: `EXEC GetCustomersByCity @City = 'London';`. [S1]
|
||||
- Multi-parameter procedure: [S1]
|
||||
```sql
|
||||
CREATE PROCEDURE GetCustomersByCity
|
||||
@City nvarchar(50),
|
||||
@PostalCode nvarchar(10)
|
||||
AS
|
||||
BEGIN
|
||||
SELECT * FROM Customers
|
||||
WHERE City = @City AND PostalCode = @PostalCode;
|
||||
END;
|
||||
```
|
||||
Executed with: `EXEC GetCustomersByCity @City = 'London', @PostalCode = 'WA1 1DP';`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 문법은 SQL Server 기준이며, MySQL은 별도 문법을 참조하라고 안내됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 반복 실행되는 조회 로직을 재사용 가능한 단위로 캡슐화할 때 쓰이는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parameterized stored procedure (SQL Server):
|
||||
```sql
|
||||
CREATE PROCEDURE GetCustomersByCity
|
||||
@City nvarchar(50)
|
||||
AS
|
||||
BEGIN
|
||||
SELECT * FROM Customers
|
||||
WHERE City = @City;
|
||||
END;
|
||||
```
|
||||
```sql
|
||||
EXEC GetCustomersByCity @City = 'London';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL Where]], [[SQL Injection]]
|
||||
- **참조 맥락:** 재사용 가능한 파라미터화 쿼리가 필요할 때 사용 — 이후 SQL Injection/Prepared Statements 챕터의 보안 논의와도 연결된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Stored Procedures — https://www.w3schools.com/sql/sql_stored_procedures.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Stored Procedures" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: sql-sum
|
||||
title: "SQL Sum"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL SUM() Function", "SUM function", "SQL 합계"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "sum", "aggregate"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_sum.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Sum]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
SUM() totals a numeric column, ignores NULLs, and can take an expression (not just a bare column) — including a value computed by joining in another table's price. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SUM() function** — calculates the total sum of values within a numeric column; ignores NULL values. [S1]
|
||||
- **Syntax** — `SELECT SUM(column_name) FROM table_name WHERE condition;`. [S1]
|
||||
- **SUM() with an expression** — the argument can be an expression like `Quantity * 10`, not just a column reference. [S1]
|
||||
- **SUM() with GROUP BY** — returns a sum per group. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Join-then-sum for real totals** — instead of assuming a flat unit price, joining the detail table to the actual `Products` table and summing `Price * Quantity` gives the real total, illustrating that SUM() arguments can encode business logic via JOIN + expression. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic sum: `SELECT SUM(Quantity) FROM OrderDetails;`. [S1]
|
||||
- With WHERE: `SELECT SUM(Quantity) FROM OrderDetails WHERE ProductId = 11;`. [S1]
|
||||
- With alias: `SELECT SUM(Quantity) AS total FROM OrderDetails;`. [S1]
|
||||
- With GROUP BY: `SELECT OrderID, SUM(Quantity) AS [Total Quantity] FROM OrderDetails GROUP BY OrderID;`. [S1]
|
||||
- With an expression: `SELECT SUM(Quantity * 10) FROM OrderDetails;`. [S1]
|
||||
- With a JOIN for real prices: `SELECT SUM(Price * Quantity) FROM OrderDetails LEFT JOIN Products ON OrderDetails.ProductID = Products.ProductID;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 매출/수량 합계 리포트의 기본 함수로, JOIN과 결합한 실제 매출 계산 예시가 소스에 직접 등장한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
SUM with expression and JOIN (SQL):
|
||||
```sql
|
||||
SELECT SUM(Price * Quantity)
|
||||
FROM OrderDetails
|
||||
LEFT JOIN Products ON OrderDetails.ProductID = Products.ProductID;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Aggregate Functions]], [[SQL Group By]], [[SQL Left Join]]
|
||||
- **참조 맥락:** 합계 리포트의 기본 함수 — 표현식·JOIN과 결합해 실제 매출/수량 계산에 쓰인다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL SUM() Function — https://www.w3schools.com/sql/sql_sum.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL SUM() Function" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: sql-syntax
|
||||
title: "SQL Syntax"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Statements", "SQL keywords", "SQL 문법"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "syntax"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_syntax.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Syntax]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Most database actions are performed with SQL statements built from easy-to-understand keywords, which are case-insensitive but conventionally written in upper-case and terminated with a semicolon. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL statements** — the unit of action against a database; consist of keywords such as `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO`. [S1]
|
||||
- **Database tables** — a database most often contains one or more named tables (e.g. "Customers"), each holding records (rows) with data; this tutorial uses the well-known Northwind sample database. [S1]
|
||||
- **Case insensitivity** — SQL keywords are NOT case sensitive (`select` is the same as `SELECT`); convention favors upper-case keywords. [S1]
|
||||
- **Semicolons** — some database systems require a semicolon to separate multiple SQL statements sent in the same call to the server. [S1]
|
||||
- **Most important SQL commands** — `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO`, `CREATE DATABASE`, `ALTER DATABASE`, `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE`, `CREATE INDEX`, `DROP INDEX`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Upper-case keyword convention** — writing keywords in upper-case (even though not required) improves readability and is the convention followed throughout the tutorial. [S1]
|
||||
- **Statement-terminator discipline** — always ending statements with `;` avoids ambiguity when multiple statements are sent together, even on systems where it isn't strictly required. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **세미콜론 사용** | 여러 SQL문을 한 번에 보낼 때 구분이 명확함 | 세미콜론을 요구하지 않는 시스템에서는 불필요해 보일 수 있음 | 다중 statement 전송이 필요하거나 이식성을 고려할 때 |
|
||||
| **세미콜론 생략** | 단일 statement 실행 시 더 간결함 | 시스템에 따라 오류가 날 수 있음 | 세미콜론을 명시적으로 요구하지 않는 단일 statement 환경 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- The following statement selects all records from the "Customers" table: [S1]
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
- A sample from the Customers table has columns `CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country` with rows like `1 | Alfreds Futterkiste | Maria Anders | Obere Str. 57 | Berlin | 12209 | Germany`. [S1]
|
||||
- Most important SQL commands (grouped by purpose): [S1]
|
||||
- Data: `SELECT`, `UPDATE`, `DELETE`, `INSERT INTO`
|
||||
- Database: `CREATE DATABASE`, `ALTER DATABASE`
|
||||
- Table: `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE`
|
||||
- Index: `CREATE INDEX`, `DROP INDEX`
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 "일부 데이터베이스 시스템만 세미콜론을 요구한다"는 서술 자체가 시스템마다 동작이 다를 수 있음을 명시하고 있다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 문서에서 정의한 대문자 키워드/세미콜론 컨벤션은 튜토리얼 전체 예제에서 일관되게 사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Select all records (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Intro]], [[SQL Select]], [[SQL Comments]]
|
||||
- **참조 맥락:** 이후 모든 SQL 예제가 따르는 표기 관례(대문자 키워드, 세미콜론)를 정의하는 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Syntax — https://www.w3schools.com/sql/sql_syntax.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: sql-union
|
||||
title: "SQL Union"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL UNION Operator", "UNION operator", "SQL 합집합"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "union"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_union.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Union]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
UNION combines the result-sets of two or more SELECT statements into one, automatically removing duplicate rows, provided every SELECT has the same number/type/order of columns. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **UNION operator** — combines the result-set of two or more SELECT statements, removing duplicates automatically. [S1]
|
||||
- **Requirements** — every SELECT must have the same number of columns, similar data types, and columns in the same order. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 UNION SELECT column_name(s) FROM table2;`. [S1]
|
||||
- **Result column naming** — result-set column names default to the first SELECT statement's column names. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Literal tag column** — a literal string like `'Customer' AS Type` in one SELECT and `'Supplier'` in the other lets a combined UNION query tag which source table each row came from. [S1]
|
||||
- **WHERE-filtered UNION** — each SELECT in a UNION can carry its own WHERE clause before being combined. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Combine and dedupe countries from two tables: `SELECT Country FROM Customers UNION SELECT Country FROM Suppliers ORDER BY Country;`. [S1]
|
||||
- Filtered UNION: `SELECT City, Country FROM Customers WHERE Country='Germany' UNION SELECT City, Country FROM Suppliers WHERE Country='Germany' ORDER BY City;`. [S1]
|
||||
- Tagged UNION distinguishing source: `SELECT 'Customer' AS Type, ContactName, City, Country FROM Customers UNION SELECT 'Supplier', ContactName, City, Country FROM Suppliers;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 중복 제거를 원치 않으면 UNION ALL을 쓰라고 명시적으로 안내함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 UNION ALL 챕터에서 중복 제거 여부만 다른 대응 연산자로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combine and dedupe two result-sets (SQL):
|
||||
```sql
|
||||
SELECT Country FROM Customers
|
||||
UNION
|
||||
SELECT Country FROM Suppliers
|
||||
ORDER BY Country;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Union All]], [[SQL Select Distinct]], [[SQL Order By]]
|
||||
- **참조 맥락:** 여러 SELECT 결과를 하나로 합쳐야 할 때의 기본 도구 — 중복 제거가 필요 없다면 UNION ALL을 대신 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL UNION Operator — https://www.w3schools.com/sql/sql_union.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL UNION Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: sql-union-all
|
||||
title: "SQL Union All"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL UNION ALL Operator", "UNION ALL operator"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "union", "union-all"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_union_all.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Union All]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
UNION ALL combines result-sets like UNION but keeps every row including duplicates, under the same same-columns/types/order requirements. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **UNION ALL operator** — combines the result-set of two or more SELECT statements, including all rows and duplicates. [S1]
|
||||
- **Requirements** — identical to UNION: same number of columns, similar data types, same column order across all SELECT statements. [S1]
|
||||
- **Syntax** — `SELECT column_name(s) FROM table1 UNION ALL SELECT column_name(s) FROM table2;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **UNION vs. UNION ALL is a dedup toggle** — same syntax and requirements as UNION; the only behavioral difference is whether duplicate rows across the combined sets survive. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **UNION** | 중복 자동 제거, 깔끔한 결과 | 중복 제거 연산으로 인해 UNION ALL보다 느릴 수 있음 | 고유 값 목록이 필요할 때 |
|
||||
| **UNION ALL** | 중복 제거 연산이 없어 더 빠름, 원본 행 수 보존 | 중복 행이 그대로 남음 | 성능이 중요하거나 중복 자체가 의미 있는 데이터(예: 개수 집계)일 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All countries including duplicates: `SELECT Country FROM Customers UNION ALL SELECT Country FROM Suppliers ORDER BY Country;`. [S1]
|
||||
- Filtered UNION ALL: `SELECT City, Country FROM Customers WHERE Country='Germany' UNION ALL SELECT City, Country FROM Suppliers WHERE Country='Germany' ORDER BY City;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 중복 제거 비용을 피하고 싶거나 중복 자체가 의미 있는 로그/집계성 쿼리에서 UNION 대신 선택된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combine result-sets keeping duplicates (SQL):
|
||||
```sql
|
||||
SELECT Country FROM Customers
|
||||
UNION ALL
|
||||
SELECT Country FROM Suppliers
|
||||
ORDER BY Country;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Union]], [[SQL Select Distinct]]
|
||||
- **참조 맥락:** UNION의 중복-보존 버전 — 성능이 중요하거나 중복이 의미 있는 경우에 UNION 대신 선택.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL UNION ALL Operator — https://www.w3schools.com/sql/sql_union_all.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL UNION ALL Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: sql-unique
|
||||
title: "SQL Unique"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL UNIQUE Constraint", "UNIQUE constraint"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "unique", "constraints"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_unique.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Unique]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
UNIQUE guarantees every value in a column is distinct — like PRIMARY KEY, but a table can have many UNIQUE constraints versus only one PRIMARY KEY. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **UNIQUE constraint** — ensures all values in a column are unique. [S1]
|
||||
- **UNIQUE vs. PRIMARY KEY** — both guarantee uniqueness, but a table can have many UNIQUE constraints, and only one PRIMARY KEY. [S1]
|
||||
- **On CREATE TABLE** — inline (`ID int NOT NULL UNIQUE`) for SQL Server/Oracle/Access, or a separate `UNIQUE (ID)` clause for MySQL. [S1]
|
||||
- **Named/multi-column UNIQUE** — `CONSTRAINT UC_Person UNIQUE (ID, LastName)` names the constraint and spans multiple columns. [S1]
|
||||
- **On ALTER TABLE** — `ALTER TABLE Persons ADD UNIQUE (ID);` for an existing table. [S1]
|
||||
- **Dropping** — `DROP INDEX UC_Person;` (MySQL) vs. `DROP CONSTRAINT UC_Person;` (SQL Server/Oracle/Access). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **MySQL 문법 차이**: 다른 벤더는 컬럼 옆에 인라인 `UNIQUE` 키워드를 쓰지만, MySQL은 별도의 `UNIQUE (ID)` 절이 필요함. 드롭 시에도 MySQL은 `DROP INDEX`, 나머지는 `DROP CONSTRAINT`로 갈린다. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- SQL Server/Oracle/Access inline: `CREATE TABLE Persons (ID int NOT NULL UNIQUE, ...);`. [S1]
|
||||
- MySQL: `CREATE TABLE Persons (ID int NOT NULL, ..., UNIQUE (ID));`. [S1]
|
||||
- Named multi-column constraint: `CONSTRAINT UC_Person UNIQUE (ID,LastName)`. [S1]
|
||||
- Add to existing table: `ALTER TABLE Persons ADD UNIQUE (ID);`. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — PRIMARY KEY가 이미 있는 컬럼 외에 "고유해야 하지만 대표키는 아닌" 컬럼(예: 이메일, 주민번호)에 흔히 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Named multi-column UNIQUE (SQL):
|
||||
```sql
|
||||
CREATE TABLE Persons (
|
||||
ID int NOT NULL,
|
||||
LastName varchar(255) NOT NULL,
|
||||
FirstName varchar(255),
|
||||
Age int,
|
||||
CONSTRAINT UC_Person UNIQUE (ID,LastName)
|
||||
);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Constraints]], [[SQL Primary Key]], [[SQL Not Null]]
|
||||
- **참조 맥락:** 대표키는 아니지만 값의 고유성을 보장해야 하는 컬럼에 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL UNIQUE Constraint — https://www.w3schools.com/sql/sql_unique.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL UNIQUE Constraint" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: sql-update
|
||||
title: "SQL Update"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL UPDATE Statement", "UPDATE statement", "SQL 수정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "update"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_update.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Update]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
UPDATE modifies existing records, and omitting its WHERE clause is a critical footgun that silently rewrites every row in the table. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **UPDATE statement** — updates or modifies one or more existing records in a table. [S1]
|
||||
- **Syntax** — `UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;`. [S1]
|
||||
- **WHERE determines scope** — the WHERE clause specifies exactly which record(s) get updated. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Missing-WHERE footgun** — the source explicitly warns: omit WHERE and ALL records in the table are updated. This is called out twice (as a "Note" and as an "Update Warning!") — a strong signal that this is the most common and costly mistake with this statement. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Update a single record: `UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1;`. [S1]
|
||||
- Update multiple records matching a condition: `UPDATE Customers SET ContactName='Juan' WHERE Country='Mexico';`. [S1]
|
||||
- Update ALL records (WHERE omitted — dangerous, shown as a cautionary example): `UPDATE Customers SET ContactName='Juan';`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. WHERE 생략의 위험성이 소스 내에서 두 차례 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 프로덕션에서 UPDATE 실행 전 WHERE 조건을 SELECT로 먼저 검증하는 습관이 소스의 경고에서 자연스럽게 도출된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Update one record (SQL):
|
||||
```sql
|
||||
UPDATE Customers
|
||||
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
|
||||
WHERE CustomerID = 1;
|
||||
```
|
||||
Update matching multiple records (SQL):
|
||||
```sql
|
||||
UPDATE Customers
|
||||
SET ContactName='Juan'
|
||||
WHERE Country='Mexico';
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Where]], [[SQL Delete]], [[SQL Insert Into]]
|
||||
- **참조 맥락:** CRUD의 Update 축 — WHERE 절 누락 위험을 항상 함께 기억해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL UPDATE Statement — https://www.w3schools.com/sql/sql_update.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL UPDATE Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: sql-views
|
||||
title: "SQL Views"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL CREATE VIEW Statement", "SQL View", "가상 테이블"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "view"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_view.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Views]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A view is a virtual table backed only by a stored SELECT definition, not a data copy — so it always reflects real-time data, and updating it requires vendor-specific syntax (ALTER VIEW vs. CREATE OR REPLACE VIEW). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **SQL view** — a virtual table based on the result-set of an SQL statement; fields come from one or more real tables. [S1]
|
||||
- **Always real-time** — the database only stores the view's SELECT definition, not a data copy, so querying a view always reflects current data. [S1]
|
||||
- **Syntax (create)** — `CREATE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition;`. [S1]
|
||||
- **Querying a view** — `SELECT * FROM view_name;`, exactly like querying a real table. [S1]
|
||||
- **Updating a view** — `ALTER VIEW` (SQL Server) vs. `CREATE OR REPLACE VIEW` (MySQL/Oracle). [S1]
|
||||
- **Dropping a view** — `DROP VIEW view_name;`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **View as a saved query with a table name** — a view can encapsulate a subquery-based filter (e.g. "products above average price") behind a simple table-like name, hiding the underlying complexity from downstream queries. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Simple filtered view: `CREATE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName FROM Customers WHERE Country = 'Brazil';`, queried as `SELECT * FROM [Brazil Customers];`. [S1]
|
||||
- View wrapping a subquery: `CREATE VIEW [Products Above Average Price] AS SELECT ProductName, Price FROM Products WHERE Price > (SELECT AVG(Price) FROM Products);`. [S1]
|
||||
- Update a view (SQL Server): `ALTER VIEW [Brazil Customers] AS SELECT CustomerName, ContactName, City FROM Customers WHERE Country = 'Brazil';`. [S1]
|
||||
- Update a view (MySQL/Oracle): `CREATE OR REPLACE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName, City FROM Customers WHERE Country = 'Brazil';`. [S1]
|
||||
- Drop a view: `DROP VIEW [Brazil Customers];`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **뷰 갱신 문법이 벤더별로 다름**: SQL Server는 `ALTER VIEW`, MySQL/Oracle은 `CREATE OR REPLACE VIEW`를 사용. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — AVG() 서브쿼리를 뷰로 감싸 재사용 가능한 이름으로 노출하는 예시가 소스에 직접 등장한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Create and query a view (SQL):
|
||||
```sql
|
||||
CREATE VIEW [Brazil Customers] AS
|
||||
SELECT CustomerName, ContactName
|
||||
FROM Customers
|
||||
WHERE Country = 'Brazil';
|
||||
|
||||
SELECT * FROM [Brazil Customers];
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL Avg]], [[SQL Create Table]]
|
||||
- **참조 맥락:** 복잡한 쿼리를 재사용 가능한 가상 테이블로 감싸야 할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Views — https://www.w3schools.com/sql/sql_view.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Views" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
id: sql-where
|
||||
title: "SQL Where"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL WHERE Clause", "WHERE clause", "SQL 조건절"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "where", "filter", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_where.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Where]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The WHERE clause filters records to only those that fulfill a specific condition, and works not just in SELECT but also in UPDATE and DELETE statements. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **WHERE clause** — extracts only records that satisfy a given condition; usable in `SELECT`, `UPDATE`, `DELETE`. [S1]
|
||||
- **WHERE syntax** — `SELECT column1, column2, ... FROM table_name WHERE condition;`. [S1]
|
||||
- **Text vs. numeric fields** — text values must be wrapped in single quotes (`'Mexico'`), while numeric fields should NOT be quoted. [S1]
|
||||
- **Comparison operators in WHERE** — `=`, `>`, `<`, `>=`, `<=`, `<>` (or `!=` in some SQL dialects), plus `BETWEEN`, `LIKE`, `IN`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Quote-by-type rule** — quote text values, never quote numeric values, when writing WHERE conditions. [S1]
|
||||
- **WHERE is statement-agnostic** — the same filtering syntax generalizes across SELECT/UPDATE/DELETE rather than being SELECT-specific. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **`=` 단일 값 비교** | 가장 단순하고 명확함 | 범위·패턴 조건 표현 불가 | 정확히 일치하는 값 하나를 찾을 때 |
|
||||
| **`BETWEEN` / `IN` / `LIKE`** | 범위·목록·패턴 조건을 간결하게 표현 | 단순 비교보다 읽기/성능 비용이 더 들 수 있음 | 범위 필터, 다중 후보값, 부분 문자열 매칭이 필요할 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Select all customers from Mexico: [S1]
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Mexico';
|
||||
```
|
||||
- Numeric fields are not quoted: [S1]
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE CustomerID = 1;
|
||||
```
|
||||
- Operators other than `=` can filter the search, e.g. greater-than: [S1]
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE CustomerID > 80;
|
||||
```
|
||||
- Operators available in the WHERE clause: `=` (equal), `>` (greater than), `<` (less than), `>=` (greater than or equal), `<=` (less than or equal), `<>` (not equal — written `!=` in some SQL versions), `BETWEEN` (range), `LIKE` (pattern search), `IN` (multiple possible values). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **`<>` vs `!=`**: 소스 자체가 "일부 SQL 버전에서는 `<>`가 `!=`로 쓰일 수 있다"고 명시 — 표준 표기(`<>`)와 방언별 표기(`!=`)가 공존함을 알려줌. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — WHERE 절은 이후 AND/OR/NOT, JOIN, GROUP BY 등 조건부 쿼리 전반에서 반복적으로 재사용되는 핵심 문법이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Filter by text value (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE Country = 'Mexico';
|
||||
```
|
||||
Filter by numeric comparison (SQL):
|
||||
```sql
|
||||
SELECT * FROM Customers
|
||||
WHERE CustomerID > 80;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Select]], [[SQL And]], [[SQL Like]], [[SQL Between]], [[SQL In]]
|
||||
- **참조 맥락:** 조건부 데이터 필터링의 기반 문서 — AND/OR/NOT, LIKE, BETWEEN, IN 챕터가 모두 이 WHERE 절 문법을 확장한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL WHERE Clause — https://www.w3schools.com/sql/sql_where.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL WHERE Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: sql-wildcards
|
||||
title: "SQL Wildcards"
|
||||
category: "Database"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["SQL Wildcard Characters", "SQL 와일드카드"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["sql", "database", "w3schools", "wildcards", "like"]
|
||||
raw_sources: ["https://www.w3schools.com/sql/sql_wildcards.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[SQL Wildcards]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Beyond `%` and `_`, standard SQL wildcards include `[]` (character set), `-` (range within brackets), and `^`/`!` (negated set) — but support for these varies significantly by database vendor. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Wildcard character** — substitutes one or more characters in a string pattern, used together with the LIKE operator. [S1]
|
||||
- **`%`** — zero or more characters. **`_`** — exactly one character. [S1]
|
||||
- **`[]`** — matches any single character within the brackets, e.g. `[bsp]` matches "b", "s", or "p". [S1]
|
||||
- **`-`** — specifies a character range inside `[]`, e.g. `[a-f]`. [S1]
|
||||
- **`^`** — matches any character NOT in the brackets (vendor-specific). [S1]
|
||||
- **`{}`** — matches any escaped character (Oracle only). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Vendor fragmentation** — `[]`/`^`/`-` are NOT supported in PostgreSQL and MySQL; `{}` is Oracle-only; MS Access uses an entirely different wildcard set (`*` instead of `%`, `?` instead of `_`, `!` instead of `^`, `#` for a single digit). [S1]
|
||||
- **Combinable wildcards** — `%` and `_` can be freely combined in one pattern (e.g. `'a__%'`). [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **표준 SQL 와일드카드 (`%`, `_`)** | PostgreSQL/MySQL/SQL Server 등 대부분 지원 | 문자 집합/범위 표현 불가 | 이식성이 중요한 경우 |
|
||||
| **`[]`/`-`/`^` 확장 와일드카드** | 문자 집합·범위·부정을 한 패턴에 표현 가능 | PostgreSQL/MySQL 미지원 | SQL Server/Access 등 지원 DB 한정 |
|
||||
| **MS Access 전용 와일드카드 (`*`,`?`,`#`,`!`)** | Access 네이티브 문법과 일치 | 다른 DB로 이식 불가 | MS Access 전용 쿼리 작성 시 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Character set match: `WHERE CustomerName LIKE '[bsp]%';` (starts with b, s, or p). [S1]
|
||||
- Range match: `WHERE CustomerName LIKE '[a-f]%';` (starts with a through f). [S1]
|
||||
- Combine `%` and `_`: `WHERE CustomerName LIKE 'a__%';` (starts with "a", at least 3 characters). [S1]
|
||||
- MS Access wildcard table — `*` (zero+ chars), `?` (single char), `[]` (char set), `!` (negated set), `-` (range), `#` (single digit), e.g. `h[oa]t` finds "hot"/"hat" but not "hit". [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **DB별 지원 차이가 소스 자체의 핵심 메시지**: `[]`,`^`,`-`는 PostgreSQL/MySQL 미지원, `{}`는 Oracle 전용, MS Access는 아예 다른 기호 체계(`*`,`?`,`#`,`!`)를 사용 — 하나의 "SQL 와일드카드" 표준이 사실상 존재하지 않음을 소스가 명시. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Like 챕터에서 소개된 `%`/`_`가 여기서 DB별 확장 와일드카드로 심화된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Character-set and range wildcards (SQL, non-MySQL/PostgreSQL):
|
||||
```sql
|
||||
SELECT * FROM Customers WHERE CustomerName LIKE '[bsp]%';
|
||||
SELECT * FROM Customers WHERE CustomerName LIKE '[a-f]%';
|
||||
```
|
||||
MS Access equivalent:
|
||||
```
|
||||
h[oa]t -- finds "hot" and "hat", but not "hit"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[SQL Tutorial]]
|
||||
- **관련 개념:** [[SQL Like]], [[SQL Where]]
|
||||
- **참조 맥락:** LIKE 패턴 매칭을 문자 집합/범위 수준으로 확장할 때 참조 — 단, DB 벤더별 지원 여부를 먼저 확인해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — SQL Wildcards — https://www.w3schools.com/sql/sql_wildcards.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "SQL Wildcards" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user