Languages
[Edit]
EN

Mysql - create new column with index on existing database table with data

13 points
Created by:
Trenton-McKinney
618

We can achieve it by executing below query.

Just change:

  • database table - posts
  • column name - category_id
  • index name - index_category_id

Example

Edit

Create database, table and insert data.

Edit

Screenshot 1:

Screenshot from Heidi SQL after execution above query - database schema
Screenshot from Heidi SQL after execution above query - database schema

Screenshot 2:

Screenshot from Heidi SQL after execution above query - inserted data
Screenshot from Heidi SQL after execution above query - inserted data

Query - create new column with index

Edit

Our database after execution

Screenshot 3:

database schema with new column and index
database schema with new column and index

Screenshot 4:

database data with new column and index and default value 1
database data with new column and index and default value 1
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MySQL - Problems

Mysql - create new column with index on existing database table with data
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join