Home > Database > Mysql Tutorial > What is the difference between db2 and mysql syntax

What is the difference between db2 and mysql syntax

青灯夜游
Release: 2020-09-15 11:16:55
Original
10221 people have browsed it

What is the difference between db2 and mysql syntax

MySQL uses case-sensitive database names, table names, and column names by default (you can control whether it is case-sensitive through the lower_case_table_names parameter), and DB2 databases are not case-sensitive.

Although MySQL and DB2 both follow and comply with the SQL92 standard and most SQL are compatible with each other, there are some differences in the implementation of some details. For example: MySQL uses the limit syntax to fetch the first few rows of data that meet the conditions, and DB2 uses the fetch syntax, etc.

Let’s take a closer look at some of the syntax differences between db2 and mysql:

1. Delete columns:

mysql:

alter table 表名 set unuesed column 字段名
Copy after login

db2: Does not provide the function of deleting columns (the solution is to delete the table and rebuild it)

2. Change the column name

mysql:

alter table 表名 change 旧字段名 新字段名 新数据类型
Copy after login

db2 : Does not provide the function of changing column names (the solution is the same as deleting, or by creating a new view)

3. Change column type

mysql :

alter table 表名 modify column 字段名 新数据类型 [新类型长度  新默认值  新注释];
Copy after login

db2 :

alter table 表名 alter 字段名 新数据类型
Copy after login

db2 can only be widened, but the data type cannot be changed

Example: Change the type length of the field mail to 256

alter table test alter mail varchar(256)
Copy after login

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

mysql :

alter table test modify mail varchar(29) not null;
Copy after login

db2 :

alter table test alter mail null/not null;
Copy after login

The above is the detailed content of What is the difference between db2 and mysql syntax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template