Get the App
SLTechnology News&Howtos  ›  Database  › 

How to add and delete columns in mysql

Shulou Source: shulou.com Published: 2022-05-31 18:42:26 10月26日 Update

This article introduces the relevant knowledge of "how to add and delete columns in mysql". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

-- add columns

CREATE TABLE register (

Id INT PRIMARY KEY AUTO_INCREMENT

-- name VARCHAR (10) DEFAULT NULL UNIQUE KEY

RegisTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ()

Fund DOUBLE (9,2) DEFAULT 1000000.00

-tel CHAR (11) NOT NULL

)

ALTER TABLE register ADD tel CHAR (11) NOT NUL

ALTER TABLE register ADD name VARCHAR (10) DEFAULT NULL UNIQUE KEY AFTER id

ALTER TABLE register ADD tel CHAR (11) NOT NULL,ADD name VARCHAR (10) DEFAULT NULL UNIQUE KEY AFTER id

-- delete a single column

ALTER TABLE register DROP name

-- delete multiple columns

ALTER TABLE register DROP fund,DROP tel

This is the end of the content of "how to add and delete columns in mysql". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Content more knowledge practical successful learning next dilemma reality situation article case editing website industry process high quality learning related output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Docker OPPO Reno Shulou Information