How to list out check constraints in a SQLite table

前端 未结 1 937
不思量自难忘°
不思量自难忘° 2021-01-20 17:37

for example I defined a table

create table demo_tab (
    name text not null unique,
    phone_number text not null check(phone_number like \'9%\')
);
         


        
1条回答
  •  南方客
    南方客 (楼主)
    2021-01-20 17:55

    You can retrieve the SQL that was used to create the table from sqlite_master:

    sqlite> create table demo_tab (
       ...>     name text not null unique,
       ...>     phone_number text not null check(phone_number like '9%')
       ...> );
    sqlite> select sql from sqlite_master where type='table' and name='demo_tab';
    CREATE TABLE demo_tab (
        name text not null unique,
        phone_number text not null check(phone_number like '9%')
    )
    

    0 讨论(0)
提交回复
热议问题