MariaDB drop partition gives syntax error - mariadb-10.2

I try to drop partition in MariaDB database table by this command:
ALTER TABLE d_tracking DROP PARTITION 20151001;
but gets an error:
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version
for the right syntax to use near '20151001' at line 1
The syntax of the command is the same as on official page https://mariadb.com/kb/en/partition-maintenance/
"SHOW CREATE TABLE d_tracking" shows:
CREATE TABLE `d_tracking` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idUser` int(11) NOT NULL,
`actionTime` datetime NOT NULL,
`action` varchar(255) NOT NULL,
PRIMARY KEY (`id`,`actionTime`),
KEY `idUser` (`idUser`),
KEY `actionTime` (`actionTime`)
) ENGINE=InnoDB AUTO_INCREMENT=28805509 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4
PARTITION BY RANGE (to_days(`actionTime`))
(PARTITION `20151001` VALUES LESS THAN (736237) ENGINE = InnoDB,
PARTITION `20160101` VALUES LESS THAN (736329) ENGINE = InnoDB,
...
PARTITION `od` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
Similar result for the command
ALTER TABLE d_tracking REORGANIZE PARTITION od INTO
( PARTITION 20220401 VALUES LESS THAN (TO_DAYS('2022-04-01'))
ENGINE=InnoDB, PARTITION od VALUES LESS THAN (MAXVALUE) ENGINE=InnoDB );
answer is:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax to use
near '20220401 VALUES LESS THAN (TO_DAYS('2022-04-01'))
ENGINE=InnoDB, PARTITION od VA' at line 1
Please help.
MariaDB server version is 10.2.24, OS Debian GNU/Linux 9.9.

Related

Why am I getting an insert blob error when using MySql v8.0 instead of v5.1?

I created the following table:
CREATE TABLE `player__main` (
`row` varbinary(256) NOT NULL,
`schema_id` int NOT NULL,
`version` int NOT NULL,
`format` tinyint NOT NULL,
`avro` mediumblob NOT NULL,
PRIMARY KEY (`row`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Then, I run my script below on MySql v5.17:
insert into player__main (row, schema_id, version, format, avro) VALUES (x'61646D696E',11,1,0,x'0A61646D69');
Query OK, 1 row affected (0.05 sec)
However, when I execute the code below in MySql v8.0:
insert into player__main (row, schema_id, version, format, avro) VALUES (x'61646D696E',11,1,0,x'0A61646D69');
I get this error:
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 'row, schema_id, version, format, avro) VALUES
(x'61646D696E',11,1,0,x'0A61646D69' at line 1
It's the same query but it returns different results depending of the version of MySql I am using.
How can I fix this?
I think the real problem here is row is a reserved keyword in 8:
ROW (R); became reserved in 8.0.2
You'll need to rename that column, or escape it going forward:
INSERT INTO player_main (`row`, ...)

Error 1064 when importing SQL generated from MySQL Workbench forward engineering

I am trying to import a schema into MySQL (MariaDB 10.1.36) and I am getting the above error. I also tried direct forward engineering in MySQL Workbench but the results are the same.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')
ENGINE = InnoDB
Sample code that fails is:
CREATE TABLE IF NOT EXISTS `example`.`adhere` (
`adhere_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`description` VARCHAR(100) NOT NULL,
`id_uuid` VARCHAR(36) NULL,
PRIMARY KEY (`adhere_id`),
INDEX `ix_tmp_autoinc` (`adhere_id` ASC) VISIBLE)
ENGINE = InnoDB
AUTO_INCREMENT = 19
DEFAULT CHARACTER SET = latin1;
I tried changing the backticks into single quotes in vain, I later removed them to same result. The expectation is to have the table created so do the rest structured like so.
remove the VISIBLE word
DEMO
CREATE TABLE IF NOT EXISTS `example`.`adhere`
(
`adhere_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`description` VARCHAR(100) NOT NULL,
`id_uuid` VARCHAR(36) NULL,
PRIMARY KEY (`adhere_id`),
INDEX `ix_tmp_autoinc` (`adhere_id` ASC)
)
Check that your version of mariadb supports invisible/visible indexes here https://mariadb.com/kb/en/library/invisible-columns/ and if not turn off the option in mysql workbench here https://dev.mysql.com/doc/workbench/en/wb-table-editor-indexes-tab.html

MySQL Workbench Executing Script on Server - Error #1064

I've spent a few hours looking at the manual and need help now correcting the below erros. Thank you.
LOG:
Executing SQL script in server
ERROR: Error 1064: 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 ''ACTION')
ENGINE = InnoDB' at line 17
SQL Code:
-- -----------------------------------------------------
-- Table `mydb`.`Patients`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Patients` (
`PatientKey` INT(11) NOT NULL,
`FirstName` VARCHAR(45) NULL,
`MiddleName` VARCHAR(45) NULL,
`LastName` VARCHAR(45) NULL,
`PhoneNumber` VARCHAR(20) NULL,
`doctors_DoctorKey` INT(11) NOT NULL,
PRIMARY KEY (`PatientKey`),
INDEX `fk_Patients_doctors1_idx` (`doctors_DoctorKey` ASC) VISIBLE,
CONSTRAINT `fk_Patients_doctors1`
FOREIGN KEY (`doctors_DoctorKey`)
REFERENCES `mydb`.`doctors` (`DoctorKey`)
ON DELETE NO ACTION
ON UPDATE NO 'ACTION')
ENGINE = InnoDB
SQL script execution finished: statements: 6 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
What I'm working with:
Server type: MySQL
Server version: 8.0 - MySQL Community Server(GPL)
MySQL Workbench 8.0 CE
Remove the word VISIBLE......
Remove the word VISIBLE; it is not valid in the version you are running.

Error forward engineer SQL DB to phpmyadmin ERROR

before you say do some google i did for 1 and half hours straight and i still haven't found a fix for this issue please if you have any knowledge about this issue share your answers
Executing SQL script in server
ERROR: Error 1064: 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 'VISIBLE,
CONSTRAINT `fk_Doctors_department1`
FOREIGN KEY (`department_name' at line 10
SQL Code:
-- -----------------------------------------------------
-- Table `GPMS_DB`.`Doctors`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `GPMS_DB`.`Doctors` (
`id` INT NOT NULL,
`F_name` VARCHAR(45) NULL,
`L_name` VARCHAR(45) NULL,
`department_name` VARCHAR(20) NOT NULL,
PRIMARY KEY (`id`, `department_name`),
INDEX `fk_Doctors_department1_idx` (`department_name` ASC) VISIBLE,
CONSTRAINT `fk_Doctors_department1`
FOREIGN KEY (`department_name`)
REFERENCES `GPMS_DB`.`department` (`name`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 8 succeeded, 1 failed

Modify table to add Partition syntax get error in MySQL

I tried the following code for table partitioning.
ALTER TABLE activity_log(PRIMARY KEY (`activityId`))
PARTITION BY RANGE( TO_DAYS(dated) ) (
PARTITION p20150101 VALUES LESS THAN (TO_DAYS('2015-01-01')),
PARTITION p20160101 VALUES LESS THAN (TO_DAYS('2016-01-01')),
PARTITION p20170101 VALUES LESS THAN (TO_DAYS('2017-01-01')),
PARTITION p20180101 VALUES LESS THAN (TO_DAYS('2018-01-01')),
);
ERROR
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 '(PRIMARY KEY (activityId))
PARTITION BY RANGE( TO_DAYS(dated) ) (
PART' at line 1
Existing Table Structure
CREATE TABLE `activity_log` (
`activityId` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`teamId` int(11) ,
`addedby` int(11),
`leadId` int(11),
`activity` VARCHAR(255),
`dated` datetime,
PRIMARY KEY (`activityId`),
) ENGINE=InnoDB AUTO_INCREMENT=496831 DEFAULT CHARSET=utf8;
What i am doing wrong. Please guide me.