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 to distinguish between db2 and mysql syntax

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

Share

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

The following content mainly brings you how to distinguish db2 and mysql grammar, the knowledge here is slightly different from books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.

By default, MySQL uses case-sensitive database names, table names, and column names (which can be controlled by the lower_case_table_names parameter), while DB2 databases are not case-sensitive.

Although both MySQL and DB2 follow and conform to the SQL92 standard and most SQL are compatible with each other, there are some differences in the implementation details. For example, MySQL uses retrieve syntax on the first few rows of data that meet the criteria, while DB2 uses fetch syntax, and so on.

Let's take a look at some of the grammatical differences between db2 and mysql:

1. Delete the column:

Mysql:

Alter table table name set unuesed column field name

Db2: does not provide the ability to delete columns (the solution is to delete tables, rebuild)

2. Change the column name

Mysql:

Alter table table name change old field name new field name new data type

Db2: does not provide the ability to change column names (the solution is the same as deletion, or by creating a new view)

3. Change the column type

Mysql:

Alter table table name modify column field name new data type [new type length new default value new comment]

Db2:

Alter table table name alter field name new data type

Db2 can only be widened and the data type cannot be changed.

Example: change the type length of field mail to 256

Alter table test alter mail varchar (256)

4. Change column restrictions (non-null, primary key)

Mysql:

Alter table test modify mail varchar (29) not null

Db2:

Alter table test alter mail null/not null

These are the details of what is the difference between db2 and mysql syntax. Please pay more attention to other related 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

Database

Wechat

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

12
Report