eolas/Databases/SQL/Update_an_SQL_table.md

19 lines
426 B
Markdown
Raw Normal View History

2022-08-05 20:30:04 +01:00
---
2022-08-16 11:58:34 +01:00
categories:
2022-08-05 20:30:04 +01:00
- Databases
2022-08-21 11:00:04 +01:00
- Programming Languages
2022-12-08 20:18:56 +00:00
tags: [SQL, relational-database]
2022-08-05 20:30:04 +01:00
---
2022-12-08 20:18:56 +00:00
# Updating an SQL table
2022-08-05 20:30:04 +01:00
2022-12-08 20:18:56 +00:00
We use the `ALTER` query to add, remove and otherwise change the structural properties of a table in the database.
2022-08-05 20:30:04 +01:00
2022-08-16 11:58:34 +01:00
## Add an additional field to existing table
2022-08-05 20:30:04 +01:00
2022-12-08 20:18:56 +00:00
This adds a `price` field to the `sales` table. The `price` field accepts data of the type `real`.
2022-08-05 20:30:04 +01:00
2022-08-16 11:58:34 +01:00
```sql
2022-08-05 20:30:04 +01:00
ALTER TABLE sales ADD price real;
2022-08-16 11:58:34 +01:00
```