How to ADD Column In 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 add a column in 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`) ); ---- --- -- ADD Column In MySQL Existing Table -- -- Lets have a look into an existing table "users" -- desc users; -- -- Now adding a new column "active" into the table "users" -- ALTER TABLE users ADD COLUMN active TINYINT UNSIGNED NOT NULL default 1; -- -- -- Finally Lets have a look into the table "users" again to get the added column -- desc users; --
-- is comment in MySQL
-- in fact it is comment in MSSQL and Oracle as well
How to ADD Column In MySQL Existing Table Example - Result in MySQL Query Editor
Related Tutorial Examples
- MySQL sample database script: Create Database using SQL Statement Example
- MySQL Sub-Query: INSERT INTO SELECT... Example
- MySQL Sub-Query: INSERT INTO SELECT *... Example
- MySQL Sub-Query: CREATE TABLE SELECT... Example
- MySQL Sub-Query: CREATE TABLE SELECT *... Example
- MySQL IF() Function Boolean Value Example
- MySQL strcmp() Function Number Value Example
- MySQL Stored Procedure Function: How to Drop a Stored Procedure Example
- MySQL Stored Procedure Function: Making hello world Function using aliase Example
- 20 steps to make CakePHP Blog Project

No comments:
Post a Comment
leave your comments here..