1

On my local machine, running show create table Projects returns this:

CREATE TABLE `Projects` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Guid` char(36) NOT NULL DEFAULT uuid(),
  `Name` varchar(400) CHARACTER SET utf8mb3 NOT NULL,
  `Description` varchar(400) CHARACTER SET utf8mb3 DEFAULT NULL,
  `ImageGuid` char(36) DEFAULT NULL,
  `Slug` varchar(400) CHARACTER SET utf8mb3 NOT NULL DEFAULT uuid(),
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_Projects_Unique_Guid` (`Guid`),
  UNIQUE KEY `IX_Projects_Unique_Slug` (`Slug`),
  CONSTRAINT `Ck_Projects_NonEmptyGuid` CHECK (`Guid` <> '00000000-0000-0000-0000-000000000000'),
  CONSTRAINT `Ck_Projects_NonEmptyImageGuid` CHECK (`ImageGuid` <> '00000000-0000-0000-0000-000000000000')
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4

On the server however, it returns this:

CREATE TABLE `Projects` (
  `Id` bigint(20) NOT NULL AUTO_INCREMENT,
  `Guid` char(36) NOT NULL DEFAULT 'uuid()',
  `Name` varchar(400) CHARACTER SET utf8mb3 NOT NULL,
  `Description` varchar(400) CHARACTER SET utf8mb3 DEFAULT NULL,
  `ImageGuid` char(36) DEFAULT NULL,
  `Slug` varchar(400) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'uuid()',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_Projects_Unique_Guid` (`Guid`),
  UNIQUE KEY `IX_Projects_Unique_Slug` (`Slug`),
  CONSTRAINT `Ck_Projects_NonEmptyGuid` CHECK (`Guid` <> '00000000-0000-0000-0000-000000000000'),
  CONSTRAINT `Ck_Projects_NonEmptyImageGuid` CHECK (`ImageGuid` <> '00000000-0000-0000-0000-000000000000')
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4

As you can see, the only difference is that on the server the uuid() default is wrapped inside single quotes.

I can't find out the reason for this.

Why is it so and how can I reconfigure the server MariaDB to omit those single quotes?

MariaDB version:
MariaDB-1:10.6.5+maria~focal

8
  • .. `Slug` varchar(400) CHARACTER SET utf8mb3 NOT NULL DEFAULT 'uuid()', .. - this is an error (or maybe misprint?) obviously. how can I reconfigure the server MariaDB to omit those single quotes? - you must execute according ALTER TABLE and set correct DEFAULT property for a column.
    – Akina
    Commented May 17, 2022 at 16:11
  • @Akina, I copied the output of show create table exactly. So it's what it is. And I have used the exact same script to create this table. In other words, the creation script was uuid() not 'uuid()'. So there must be something related to the MariaDB instance. Commented May 18, 2022 at 4:33
  • Not reproduced. dbfiddle.uk/… And I have used the exact same script to create this table. In other words, the creation script was uuid() not 'uuid()'. So there must be something related to the MariaDB instance. I doubt strongly. What client do you use? Your issue looks like client/access library/framework issue.
    – Akina
    Commented May 18, 2022 at 4:37
  • That's why I can't find the problem. I'm using MariaDB's official docker. I use the same docker-compose.yml file for both development and production (except ports and passwords). I use Adminer as my web tool. But I tested show create table using C# and EF Core for MariaDB and it printed the same 'uuid()'. Commented May 18, 2022 at 4:44
  • It's not interesting how you test the structure, only the way used for table creation should be investigated. Anycase this is not MariaDB issue - it never takes the initiative and does strictly what you was told.
    – Akina
    Commented May 18, 2022 at 4:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.