代码语句: ALTER TABLE employees
MODIFY(last_name VARCHAR(30));
报错信息:
check the manual that corresponds to your MySQL server version for the right syntax to use near '(last_name VARCHAR(30))' at line 2
employees表是个只有列名和数据类型的空表
----------------+--------------+------+-----+---------+----------------+
Field | Type | Null | Key | Default | Extra |
----------------+--------------+------+-----+---------+----------------+
employee_id | int(6) | NO | PRI | NULL | auto_increment |
first_name | varchar(20) | YES | | NULL | |
last_name | varchar(25) | YES | | NULL | |
email | varchar(25) | YES | | NULL | |
phone_number | varchar(20) | YES | | NULL | |
job_id | varchar(10) | YES | MUL | NULL | |
salary | double(10,2) | YES | | NULL | |
commission_pct | double(4,2) | YES | | NULL | |
manager_id | int(6) | YES | | NULL | |
department_id | int(4) | YES | MUL | NULL | |
----------------+--------------+------+-----+---------+----------------+
4 个解决方案
#1
很不解,而且我用delete 删除一个表格数据后,用rollback;回滚无效,不能够找回数据,刚接触学习mysql,请大神指教
#2
MODIFY 的问题,建议你看官方文档语法说明
http://dev.mysql.com/doc/refman/5.7/en/alter-table.html
| MODIFY [COLUMN] col_name column_definition
[FIRST | AFTER col_name]
http://dev.mysql.com/doc/refman/5.7/en/alter-table.html
| MODIFY [COLUMN] col_name column_definition
[FIRST | AFTER col_name]
#3
ROLLBACK 的问题,这个是在事务中有效,如果你的操作不在事务中(比如操作没有开事务,或者是已经提交了事务),那么自然无法ROLLBACK
具体的也建议你看官方文档:
http://dev.mysql.com/doc/refman/5.7/en/innodb-autocommit-commit-rollback.html
具体的也建议你看官方文档:
http://dev.mysql.com/doc/refman/5.7/en/innodb-autocommit-commit-rollback.html
#4
MODIFY 后面没有括号
#1
很不解,而且我用delete 删除一个表格数据后,用rollback;回滚无效,不能够找回数据,刚接触学习mysql,请大神指教
#2
MODIFY 的问题,建议你看官方文档语法说明
http://dev.mysql.com/doc/refman/5.7/en/alter-table.html
| MODIFY [COLUMN] col_name column_definition
[FIRST | AFTER col_name]
http://dev.mysql.com/doc/refman/5.7/en/alter-table.html
| MODIFY [COLUMN] col_name column_definition
[FIRST | AFTER col_name]
#3
ROLLBACK 的问题,这个是在事务中有效,如果你的操作不在事务中(比如操作没有开事务,或者是已经提交了事务),那么自然无法ROLLBACK
具体的也建议你看官方文档:
http://dev.mysql.com/doc/refman/5.7/en/innodb-autocommit-commit-rollback.html
具体的也建议你看官方文档:
http://dev.mysql.com/doc/refman/5.7/en/innodb-autocommit-commit-rollback.html
#4
MODIFY 后面没有括号