Drop Column From MySQL Existing Table Example

How to Drop 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 Drop 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 Drop Column From Existing Table
--
-- Lets have a look an existing table "users"
--
desc users;
--
-- Now drop the column "active" from the table "users"
--
ALTER TABLE users DROP COLUMN active;
--
--
-- Finally Lets have a look into the table "users" again to get the desired output
--
desc users;
--

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

How to Drop 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. MySQL IF() Function Boolean Value Example
  3. MySQL strcmp() Function Number Value Example
  4. How to ADD Column In MySQL Existing Table Example
  5. How To Find MySQL SERVER VERSION Information
  6. Operator precedence in SQL Command MySQL Example
  7. Arithmetic operators in SQL Command MySQL Example
  8. Describe Table Structure using SQL Command MySQL Example
  9. MySQL Stored Procedure: INSERT INTO SELECT... Example
  10. MySQL Stored Procedure: CREATE TABLE SELECT... Example
  11. 20 steps to make CakePHP Blog Project

No comments:

Post a Comment

leave your comments here..