Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of adding Fields in mysql

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly gives you a brief introduction to the method of adding fields to mysql. You can look up the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on the method of adding fields in mysql can bring you some practical help.

How does mysql add fields?

Mysql adds two fields:

Mysql > create table id_name (id int,name varchar (20)); Query OK, 0 rows affected (0.13 sec) mysql > alter table id_name add age int,add address varchar (11); Query OK, 0 rows affected (0.13 sec) Records: 0 Duplicates: 0 Warnings: 0mysql > desc id_name +-+ | Field | Type | Null | Key | Default | Extra | +-+- -+ | id | int (11) | YES | | NULL | | name | varchar (20) | YES | | NULL | | age | int (11) | YES | | NULL | | address | varchar (11) | YES | | NULL | | + -+ 4 rows in set (0.00 sec)

Add a field to mysql:

Alter table user add COLUMN new1 VARCHAR (20) DEFAULT NULL; / / add a field, default is empty alter table user add COLUMN new2 VARCHAR (20) NOT NULL; / / add a field, default cannot be empty

Here's how to add fields to mysql. If you want to know about other related issues, you can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 252

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report