ob 的版本:我用 docker 部署的,OceanBase_CE 4.2.1.8
desc terminal_session;
±------------±--------------±-----±-----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±------------±--------------±-----±-----±--------±------+
| id | char(32) | NO | PRI | NULL | |
| user | varchar(128) | NO | | NULL | |
| asset | varchar(1024) | NO | | NULL | |
| system_user | varchar(128) | NO | | NULL | |
| login_from | varchar(2) | NO | | NULL | |
| is_finished | tinyint(1) | NO | | NULL | |
| has_replay | tinyint(1) | NO | | NULL | |
| has_command | tinyint(1) | NO | | NULL | |
| date_start | datetime(6) | NO | | NULL | |
| date_end | datetime(6) | YES | | NULL | |
±------------±--------------±-----±-----±--------±------+
10 rows in set (0.002 sec)
obclient [jumpserver]> desc terminal;
±-------------±-------------±-----±-----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±-------------±-------------±-----±-----±--------±------+
| id | char(32) | NO | PRI | NULL | |
| name | varchar(32) | NO | UNI | NULL | |
| remote_addr | varchar(128) | NO | | NULL | |
| ssh_port | int(11) | NO | | NULL | |
| http_port | int(11) | NO | | NULL | |
| is_accepted | tinyint(1) | NO | | NULL | |
| is_deleted | tinyint(1) | NO | | NULL | |
| date_created | datetime(6) | NO | | NULL | |
| comment | longtext | NO | | NULL | |
±-------------±-------------±-----±-----±--------±------+
9 rows in set (0.003 sec)
stmt_query (ob_sql.cpp:222) [1056][T1_L0_G0][T1][YB4204030203-0006226E5405325C-0-0] [lt=25][errcode=-5031] fail to handle text query(stmt=ALTER TABLE terminal_session
ADD COLUMN terminal_id
char(32) NULL , ADD CONSTRAINT terminal_session_terminal_id_5278f31c_fk_terminal_id
FOREIGN KEY (terminal_id
) REFERENCES terminal
(id
), ret=-5031)
上面语句分开执行就可以成功