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 to mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces the method of adding fields to mysql, which has a certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

When writing sql statements in MySQL, it is very important to add fields, for example, when the created table is not enough to meet the requirements, you need to add fields, which has met the requirements.

First, take the table created below as an example:

CREATE TABLE IF NOT EXISTS `user` (`id` INT UNSIGNED AUTO_INCREMENT, `phone` CHAR (11) NOT NULL DEFAULT'', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8

In the past, only the mobile phone number was saved, but now the information is more complete, and the name and creation time are required.

At this point, you need to use the method of adding fields.

ALTER TABLE `user`ADD `username` varchar (20) NULL DEFAULT''COMMENT' username 'AFTER `phone`, ADD `create_ at`username` creation time' AFTER `username`

AFTER means to add after a field. If not, add it to the end.

When creating tables and referring to other people's tables, it takes time to set up templates, such as using Navicat Premium tools to view other people's table information.

Thank you for reading this article carefully. I hope it will be helpful for everyone to share the method of adding fields in mysql. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

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: 0

*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

Wechat

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

12
Report