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

How does MySQL operate the datasheet

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to operate the datasheet by MySQL". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to operate the datasheet with MySQL.

The method of manipulating the data table by MySQL is not complicated. Here is a detailed description of how to add fields, modify fields, delete fields, get table names and other operations in MYSQL. I hope it will be helpful for you to learn how to add fields in MySQL.

The method of adding fields in MySQL is not complicated. Here is a detailed description of how to add fields and modify fields in MYSQL. I hope it will be helpful for you to learn how to add fields in MySQL.

1 add table field

Alter table table1 add transactor varchar (10) not Null;alter table table1 add id int unsigned not Null auto_increment primary key

An example of a statement added after a specific field:

ALTER TABLE ADD [constraint]; ALTER TABLE MyTableName ADD newDBField varchar (30) NULL AFTER existDBField;ALTER TABLE tableName001 ADD WebAdminPass varchar (30) NULL AFTER Result

two。 Modify the field type of a table and specify it as empty or non-empty

Alter table table name change field name field name field type [allow non-null]; alter table table name modify field name field type [allow non-null]; alter table table name modify field name field type [allow non-null]

3. Modify the field name of a table and specify it as empty or non-empty

Alter table table name change field original name field new name field type [whether non-null is allowed

4 if you want to delete a field, you can use the command:

ALTER TABLE mytable DROP field name

Mysql SQL gets the query statement of table name & field name

1: query all table names in the database

Select table_name from information_schema.tables where table_schema='csdb' and table_type='base table';table_schema: the database name information_schema represents the system library. Table_type='base table': restricts querying only the base table.

2: query all field names of the specified table in the specified database column_name

Select column_name from information_schema.columns where table_schema='csdb' and table_name='users'; table_schema: database name table_name: table name

Examples of work are used:

Select count (*) from information_schema.columns where table_schema='yanfa' and table_name='tableName001' and column_name='Result1'; # select table_name from information_schema.tables where table_schema='yanfa' and table_type='base table'; so far, I believe you have a deeper understanding of "how MySQL operates the data table". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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

Database

Wechat

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

12
Report