database icon indicating copy to clipboard operation
database copied to clipboard

enum type

Open deba12 opened this issue 3 years ago • 2 comments

Please add enum type in table schema. From what I have read enum type can be emulated in oracle,sqlite,mssql with check For mssql

create table sizes (
 size varchar(10) NOT NULL CHECK (name IN('small', 'medium', 'large'))
)

For sqlite

create table sizes (
 size TEXT CHECK( pType IN ('small','medium','large'))
)

For oracle

create table sizes (
 size VARCHAR2(10) CHECK( name IN ('small','medium','large'))
)

For postregres

CREATE TYPE size_enum AS ENUM ('small', 'medium', 'large');
create table sizes (
 size size_enum;
)

And finally mysql

create table sizes (
 size enum('small','medium','large');
)

And php can be something like

$db->schema()->create('size', static function(CreateTable $table) {
  $table->enum('size, ['small', 'medium', 'large']);
});

What do you think?

Cheers,

deba12 avatar May 06 '21 11:05 deba12

I like this idea, but the postgresql examples has two queries. I think that the below example also works for postgresql

create table sizes (
 size VARCHAR2(10) CHECK( size IN ('small','medium','large'))
)

sorinsarca avatar May 09 '21 18:05 sorinsarca

I am not proficient enough to say will it works. I can test with sqlite3 and mysql.

deba12 avatar May 10 '21 08:05 deba12