Skip to content

Commit 964bcf2

Browse files
committed
docs(ibm-db2): add and update notes
1 parent 3d38049 commit 964bcf2

4 files changed

+44
-3
lines changed

Diff for: notes/2025-04-09-ibm-db2-add-column-en.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Adding a Column to an Existing Table in IBM Db2
3+
lang: en
4+
layout: post
5+
audio: false
6+
translated: false
7+
generated: true
8+
---
9+
10+
To add a column to an existing table in IBM Db2, you use the `ALTER TABLE` statement with the `ADD COLUMN` clause. Here’s the basic syntax:
11+
12+
```sql
13+
ALTER TABLE table_name
14+
ADD COLUMN column_name data_type [constraints];
15+
```
16+
17+
### Example
18+
Suppose you have a table named `employees` and you want to add a column called `phone_number` with a data type of `VARCHAR(15)`:
19+
20+
```sql
21+
ALTER TABLE employees
22+
ADD COLUMN phone_number VARCHAR(15);
23+
```
24+
25+
### Key Points
26+
1. **Table Name**: Replace `table_name` with the name of your existing table.
27+
2. **Column Name**: Specify the new column name (e.g., `phone_number`).
28+
3. **Data Type**: Define the data type (e.g., `VARCHAR`, `INTEGER`, `DATE`, etc.).
29+
4. **Constraints (Optional)**: You can add constraints like `NOT NULL`, `DEFAULT`, or `CHECK` if needed. For example:
30+
```sql
31+
ALTER TABLE employees
32+
ADD COLUMN phone_number VARCHAR(15) NOT NULL DEFAULT 'N/A';
33+
```
34+
35+
5. **Existing Data**: When you add a column, Db2 will populate it with `NULL` values for existing rows unless you specify a `DEFAULT` value.
36+
37+
### Notes
38+
- You need appropriate permissions (e.g., `ALTER` privilege) on the table to perform this operation.
39+
- If the table is large, this operation might take some time and could lock the table, depending on the Db2 version and configuration.
40+
41+
Let me know if you need help with a specific example or additional details!

Diff for: notes/2025-04-09-ibm-db2-describe-table-en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Using the DESCRIBE Command in IBM DB2
2+
title: Using the DESCRIBE Command in IBM Db2
33
lang: en
44
layout: post
55
audio: false

Diff for: notes/2025-04-09-ibm-db2-sql-syntax-en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: IBM DB2 SQL Syntax Exception
2+
title: IBM Db2 SQL Syntax Exception
33
lang: en
44
layout: post
55
audio: false

Diff for: notes/2025-04-09-ibm-db2-table-sql-en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: IBM DB2 Table SQL
2+
title: IBM Db2 Table SQL
33
lang: en
44
layout: post
55
audio: false

0 commit comments

Comments
 (0)