# Pt-online-schema-change errors on altering default value

**URL:** <https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867>\
**Category:** MySQL & MariaDB\
**Tags:** mysql, percona\
**Created:** [May 27, 2022, 1:27pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867 "2022-05-27T13:27:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![psteinheuser](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@psteinheuser](https://forums.percona.com/u/psteinheuser)\
**Post date:** [May 27, 2022, 1:27pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/1 "2022-05-27T13:27:02Z")

</div>

Hi  
Trying to alter the default value to current\_timestamp.  
The column name is datetime (not my idea) and this is a AWS RDS cluster version 5.7.mysql\_aurora.2.10.2  
ex. --alter “ALTER `datetime` SET DEFAULT CURRENT\_TIMESTAMP”  
I’ve tried all different kinds of syntax and getting this error:  
DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘datetime’ SET DEFAULT CURRENT\_TIMESTAMP’ at line 1 [for Statement “ALTER TABLE `<db>`.`_<table>` ALTER ‘datetime’ SET DEFAULT CURRENT\_TIMESTAMP”] at /usr/bin/pt-online-schema-change line 9490.

The current column definition:  
`datetime` datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’,  
and it’s indexed  
Any help appreciated.

Peter

---

<div class="post-metadata">

**Author:** ![psteinheuser](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@psteinheuser](https://forums.percona.com/u/psteinheuser)\
**Post date:** [May 27, 2022, 2:50pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/2 "2022-05-27T14:50:25Z")

</div>

Never mind - I see you can’t use current\_timestamp with datetime

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 27, 2022, 4:56pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/3 "2022-05-27T16:56:13Z")

</div>

@psteinheuser  
Yes you can

```auto
CREATE TABLE `times_tests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `name` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)

```

Test Suite: [Online PHP/Java/C++... editor and compiler | paiza.IO](https://paiza.io/projects/e/CNjMuiD6RepI0Df6OeQ2Gg)

---

<div class="post-metadata">

**Author:** ![psteinheuser](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@psteinheuser](https://forums.percona.com/u/psteinheuser)\
**Post date:** [May 27, 2022, 5:12pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/4 "2022-05-27T17:12:37Z")

</div>

So I obviously have some kind of syntax error here - what am I doing wrong?  
pt-online-schema-change --dry-run --max-load Threads\_connected --critical-load Threads\_running=20 --alter “ALTER column datetime SET DEFAULT CURRENT\_TIMESTAMP” D=skoutdb\_1,t=sh\_userproperties,[h=skoutdb1-test-instance-0.csog6rjwxnsr.us-west-2.rds.amazonaws.com](http://h=skoutdb1-test-instance-0.csog6rjwxnsr.us-west-2.rds.amazonaws.com) --user root --password $MYSQL\_PWD  
Operation, tries, wait:  
analyze\_table, 10, 1  
copy\_rows, 10, 0.25  
create\_triggers, 10, 1  
drop\_triggers, 10, 1  
swap\_tables, 10, 1  
update\_foreign\_keys, 10, 1  
Starting a dry run. `skoutdb_1`.`sh_userproperties` will not be altered. Specify --execute instead of --dry-run to alter the table.  
Creating new table…  
Created new table skoutdb\_1.\_sh\_userproperties\_new OK.  
Altering new table…  
2022-05-27T09:05:54 Dropping new table…  
2022-05-27T09:05:55 Dropped new table OK.  
Dry run complete. `skoutdb_1`.`sh_userproperties` was not altered.  
(in cleanup) Error altering new table `skoutdb_1`.`_sh_userproperties_new`: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CURRENT\_TIMESTAMP’ at line 1 [for Statement “ALTER TABLE `skoutdb_1`.`_sh_userproperties_new` ALTER column datetime SET DEFAULT CURRENT\_TIMESTAMP”] at /usr/bin/pt-online-schema-change line 9490.

---

<div class="post-metadata">

**Author:** ![psteinheuser](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@psteinheuser](https://forums.percona.com/u/psteinheuser)\
**Post date:** [May 27, 2022, 5:58pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/5 "2022-05-27T17:58:08Z")

</div>

pt-online-schema-change 3.2.1  
All the examples I see in Percona or mysql use “create table” or “add column” - I’m trying to change an existing column. I’m having trouble finding useful doc for this.  
In pt-online-schema-change, I’ve tried alter, modify, change in every permutation I can think with no success. I notice if I use pt-online-schema-change and ADD a column, it seems to work.  
–alter “add test1 datetime default current\_timestamp not null”  
Is this some pt-online-schema-change bug or not supported. Or is there a workaround?  
I apologize if I’m missing some obvious examples.

---

<div class="post-metadata">

**Author:** ![psteinheuser](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@psteinheuser](https://forums.percona.com/u/psteinheuser)\
**Post date:** [May 27, 2022, 6:30pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/6 "2022-05-27T18:30:29Z")

</div>

Maybe this is an AWS “thing” since this is aurora mysql and I can’t even directly alter the table.  
mysql\> alter table sh\_userproperties alter datevalue SET DEFAULT CURRENT\_TIMESTAMP;  
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CURRENT\_TIMESTAMP’ at line 1

---

<div class="post-metadata">

**Author:** ![Michael\_Coburn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/michael_coburn/32/18_2.png) [@Michael\_Coburn](https://forums.percona.com/u/Michael_Coburn)\
**Post date:** [May 27, 2022, 6:31pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/7 "2022-05-27T18:31:12Z")

</div>

Hi @psteinheuser

Have you tried looking at the debug output? For example:

```auto
PTDEBUG=1 pt-online-schema-change ...

```

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 27, 2022, 8:24pm UTC](https://forums.percona.com/t/pt-online-schema-change-errors-on-altering-default-value/15867/9 "2022-05-27T20:24:43Z")

</div>

Your SQL is wrong. You need to use the correct SQL syntax for modifying a column.

> **[Online editor and compiler](https://paiza.io/projects/e/rFxfY8zOPqJgsiYU9tRHnw)**
>
> Paiza.IO is online editor and compiler. Java, Ruby, Python, PHP, Perl, Swift, JavaScript... You can use for learning programming, scraping web sites, or writing batch
