Skip to content

Instantly share code, notes, and snippets.

@kovid-r
Last active May 19, 2020 13:08
Show Gist options
  • Save kovid-r/1c7f8cde5ab6e4c4817fdc104a9cc3d9 to your computer and use it in GitHub Desktop.
Save kovid-r/1c7f8cde5ab6e4c4817fdc104a9cc3d9 to your computer and use it in GitHub Desktop.
Sample Data for Casting in SQL
create database if not exists cast_ex;
create table if not exists cast_ex.table_1 (
val_int int(10) not null,
val_int_char varchar(10) not null,
val_str varchar(10) not null
);
insert into cast_ex.table_1
with recursive seq
as (
select 1 as val union all
select val + 1
from seq
where val < 1000
)
select val as val_int,
cast(val as char) as val_str,
substring(md5(val),1,10) as val_str
from seq;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment