pingcap / pingcap/tidb

Allows default values for columns in tidb to set functions

Open
#41,583 0 comments 0 reactions 0 assignees View on GitHub
type/feature-request
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Feature Request

**Is your feature request related to a problem? Please describe:**

In oracle, the default values of columns can be set functions:
create table t(month varchar2(2) default to_char(sysdate,'MM'));

But in TiDB , this is not allowed,the default values for columns can only be constants or certain functions specified.
This will cause the table to be unable to be migrated from oracle to tidb.

TiDB documentation: https://docs.pingcap.com/zh/tidb/stable/data-type-default-values

**Describe the feature you'd like:**

Default values for columns in tidb can be set to functions,like this is allowed:
create table t(month varchar(2) default date_format(current_timestamp,'%m'));

**Describe alternatives you've considered:**

no alternatives.

**Teachability, Documentation, Adoption, Migration Strategy:**

no

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.