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

What is the difference between db2 and mysql syntax

青灯夜游
青灯夜游Original
2019-05-13 10:44:0110191browse

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 字段名

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 旧字段名 新字段名 新数据类型

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 字段名 新数据类型 [新类型长度  新默认值  新注释];

db2 :

alter table 表名 alter 字段名 新数据类型

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)

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;

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!

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