v.20.11New Feature

Allow Primary Key Specification in CREATE TABLE Query for SQL Compatibility

Allow specify primary key in column list of CREATE TABLE query. This is needed for compatibility with other SQL dialects. #15823 (Maksim Kita).
Allows specifying the primary key directly within the column list of the CREATE TABLE query for better compatibility with other SQL dialects.

Why it matters

This feature addresses the need for seamless compatibility with SQL dialects that define primary keys inline with column definitions. It simplifies table creation and reduces the cognitive load for users migrating from or working across different SQL databases.

How to use it

When creating a table, users can define the primary key by adding the PRIMARY KEY constraint directly to the relevant column(s) within the column list of the CREATE TABLE statement, like this:

CREATE TABLE example (
id Int32 PRIMARY KEY,
name String
) ENGINE = ...