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>
pull/5651/head
Ashutosh Kumar 7 months ago committed by GitHub
parent 3308387e20
commit f1fbca6fc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      src/data/roadmaps/sql/content/102-ddl/101-alter-table.md

@ -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…
Cancel
Save