Under what circumstances can the same table have duplicate field names?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 在什么情况下同一个表能出现重复字段名?

| username: 像风一样的男子

I found that there are two fields with the same name in a table, and all attributes are the same.

The strange thing is that the field names are the same, but the data inside is different!

When I try to add a new field, it reports an error:
ALTER TABLE soa_system.app_version_control_history
ADD COLUMN force_upgrade_range tinyint(1) NULL COMMENT ‘Force upgrade range 1: Minimum version 2: Specified version’ AFTER force_upgrade

1060 - Duplicate column name ‘force_upgrade_range’

| username: Kongdom | Original post link

Please share the table creation statement, it’s amazing.

| username: 像风一样的男子 | Original post link

CREATE TABLE app_version_control_history (
id bigint(19) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */ COMMENT ‘Primary key id’,
app_id int(11) NOT NULL COMMENT ‘xxxxxx’,
app_type tinyint(1) NOT NULL COMMENT ‘app type (0: IOS; 1: Android)’,
app_version varchar(128) COLLATE utf8mb4_general_ci NOT NULL COMMENT ‘app version number’,
zip_download_url varchar(255) COLLATE utf8mb4_general_ci NOT NULL COMMENT ‘download URL’,
description text COLLATE utf8mb4_general_ci NOT NULL COMMENT ‘description’,
notes varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ‘’ COMMENT ‘notes’,
force_upgrade tinyint(1) NOT NULL COMMENT ‘force upgrade (0: not forced; 1: forced)’,
force_upgrade_range tinyint(1) DEFAULT NULL COMMENT ‘force upgrade range 1: minimum version 2: specified version’,
force_upgrage_range tinyint(1) DEFAULT NULL COMMENT ‘force upgrade range 1: minimum version 2: specified version’,
force_app_version_num int(0) DEFAULT NULL COMMENT ‘minimum version for forced upgrade, versions below this need to be upgraded’,
create_id bigint(19) NOT NULL COMMENT ‘creator’,
create_time datetime NOT NULL COMMENT ‘creation time’,
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘update time’,
title varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ‘title’,
sub_title varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ‘subtitle’,
warning varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ‘warning’,
positive_btn varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ‘confirm button’,
negative_btn varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT ‘cancel button’,
del_flag tinyint(1) NOT NULL DEFAULT ‘0’ COMMENT ‘delete flag 0 for not deleted, 1 for deleted’,
PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci /*T![auto_rand_base] AUTO_RANDOM_BASE=630001 */ COMMENT=‘app version upgrade control table’;

| username: zhanggame1 | Original post link

Take a look at these two columns in information_schema.columns.

| username: Kongdom | Original post link

One is “upgrade,” and the other is “upgrage” :yum:

| username: 像风一样的男子 | Original post link

Master, you have sharp eyes; I must have been seeing things.

| username: Kongdom | Original post link

:wink: I discovered it using a comparison tool. Initially, it executed successfully on my local machine, which I found unbelievable. So, I used a comparison tool to check, and the differences immediately became apparent~

| username: Fly-bird | Original post link

Impressive. Amazing.

| username: andone | Original post link

Awesome, expert!

| username: zhanggame1 | Original post link

Good eyesight, I actually didn’t notice it.

| username: ShawnYan | Original post link

dg :wink:

It turns out that working overtime on weekends is not advisable.

| username: Jellybean | Original post link

To do a good job, one must first sharpen one’s tools.

| username: Kongdom | Original post link

:wink: Right, that makes sense.

| username: 像风一样的男子 | Original post link

In the middle of winter, weekends should be spent lying in bed and sleeping.

| username: oceanzhang | Original post link

The field names “upgrade” and “upgrage” are different. In theory, a DBA is a meticulous profession and should not make such mistakes.

| username: swino | Original post link

Too similar, you can’t tell without looking closely.

| username: oceanzhang | Original post link

It’s still better to be meticulous and careful.

| username: oceanzhang | Original post link

Therefore, the profession of a DBA can affect a person’s habits and level of meticulousness.

| username: andone | Original post link

I also misread it.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.