mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-01-17 14:18:17 +01:00
Fix alter table query (#5137)
* Update 101-alter-table.md Previously : ALTER TABLE tableName ALTER COLUMN columnName TYPE newDataType; results in syntax error Now: ALTER TABLE tableName MODIFY COLUMN columnName newDataType; * Update 101-alter-table.md Added how to drop an primary key * Update src/data/roadmaps/sql/content/102-ddl/101-alter-table.md Co-authored-by: dsh <daniel.s.holdsworth@gmail.com> --------- Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com> Co-authored-by: dsh <daniel.s.holdsworth@gmail.com>
This commit is contained in:
parent
3308387e20
commit
f1fbca6fc9
@ -46,7 +46,7 @@ To modify the datatype of a column:
|
||||
|
||||
```sql
|
||||
ALTER TABLE tableName
|
||||
ALTER COLUMN columnName TYPE newDataType;
|
||||
MODIFY COLUMN columnName newDataType;
|
||||
```
|
||||
|
||||
## Add/Drop Constraints
|
||||
@ -66,4 +66,10 @@ ALTER TABLE tableName
|
||||
DROP CONSTRAINT constraintName;
|
||||
```
|
||||
|
||||
In conclusion, `ALTER TABLE` in SQL lets you alter the structure of an existing table. This is a powerful command that lets you dynamically add, modify, and delete columns as well as the constraints placed on them. It ensures you are more flexible in dealing with changing data storage requirements.
|
||||
To drop PRIMARY KEY:
|
||||
|
||||
```sql
|
||||
ALTER TABLE table_name
|
||||
DROP PRIMARY KEY;
|
||||
|
||||
In conclusion, `ALTER TABLE` in SQL lets you alter the structure of an existing table. This is a powerful command that lets you dynamically add, modify, and delete columns as well as the constraints placed on them. It ensures you are more flexible in dealing with changing data storage requirements.
|
||||
|
Loading…
x
Reference in New Issue
Block a user