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

Add, delete, change and search command of MySQL database

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the "add, delete, change and search command of MySQL database". In the daily operation, I believe that many people have doubts about the add, delete, change and search command of MySQL database. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "add, delete, change and search command of MySQL database". Next, please follow the editor to study!

Create a database

CREATE DATABASE database_name

Create a tabl

CREATE TABLE `user` (`id` int (11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8

Delete tabl

DROP TABLE IF EXISTS `user`

Add a field:

"ALTER TABLE `user`ADD `id` int (11) NOT NULL DEFAULT'0' COMMENT 'ID'" ALTER TABLE `user`ADD `name` VARCHAR (20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT' name'

Delete a field

ALTER TABLE `user` DROP column name

Rename

ALTER TABLE table_name CHANGE old_field_name new_field_name field_type

Modify Typ

Alter table T1 change b b bigint not null; alter table infos change list list tinyint not null default'0'

Indexing

Alter table T1 rename T2 * * MySQL > alter table tablename change depno depno int (5) not null; mysql > alter table tablename add index index name (field name 1 [, field name 2 …]) ; mysql > alter table tablename add index emp_name (name); mysql > alter table tablename add primary key (id) with primary keywords; mysql > alter table tablename add unique emp_name2 (cardnumber) with unique restrictions; delete an index mysql > alter table tablename drop index emp_name; to modify the table:

Add fields to Thinkphp3.2, such as:

M ('admin')-> execute ("ALTER TABLE `admin` ADD `id` int (11) NOT NULL DEFAULT' 0' COMMENT 'ID'"); M (' admin')-> execute ("ALTER TABLE `admin` ADD `name` varchar (20) DEFAULT NULL COMMENT 'name'"). At this point, the study on "commands for adding, deleting, changing and searching MySQL database" is over. I hope you can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report