Modify Column From MySQL Existing Table Example

How to Modify Column From MySQL Existing Table Example

Open your MySQL Query Editor then copy & paste the below code to make a table "users"

Then copy & paste the below code to Modify a column from a MySQL Existing table "users"

----------- making a table users ----
----
CREATE TABLE users(
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
username VARCHAR(255) NOT NULL,
password CHAR(40) NOT NULL,
PRIMARY KEY(`id`)
);

-- MySQL Modify Column From Existing Table
--
-- Lets have a look an existing table "users"
--
desc users;
--
-- Now Modify column "active" from the table "users"
--
ALTER TABLE users Modify COLUMN active INT NOT NULL default 1;
--
--
-- Finally Lets have a look into the table "users" again to get the desired result
--
desc users;
--

      -- is comment in MySQL
      -- in fact it is comment in MSSQL and Oracle as well
   

How to Modify Column From MySQL Existing Table Example - Result in MySQL Query Editor

 

Related Tutorial Examples

  1. MySQL sample database script: Create Database using SQL Statement Example
  2. How to Drop Column From MySQL Existing Table Example
  3. SELECT distinct... SQL Command MySQL Example
  4. SELECT specific row(s) of a Table using SQL Command MySQL Example
  5. SELECT all rows of a Table using SQL Command MySQL Example
  6. Inserting data into Table(s) using SQL Command MySQL Example
  7. Creating a Table(s) with datatype using SQL Command MySQL Example
  8. MySQL concat operator SQL Example
  9. MySQL NULL to empty string Example
  10. MySQL Stored Procedure: Creating Table using Stored Procedure Example
  11. 20 steps to make CakePHP Blog Project

No comments:

Post a Comment

leave your comments here..