print "Using database observations"
use observations
go

print "Creating table fors"
go

Create table fors
(
	dp_id			varchar(45) not null,
	lst			float null,
	utc			float null,
	tpl_id			varchar(30) null,
	tpl_name		varchar(30) null,
	tpl_nexp		smallint null,
	tpl_expno		smallint null,
	ins_coll_name		varchar(10) null,
	ins_gris1_posang	float null,
	ins_filt1_name		varchar(15) null,
	ins_filt2_name		varchar(15) null,
	ins_filt3_name		varchar(15) null,
	ins_filt4_name		varchar(15) null,
	ins_gris1_name		varchar(15) null,
	ins_gris1_disp		float null,
	ins_gris1_wlen		float null,
	ins_slit_name		varchar(20) null,
	ins_slit_len		float null,
	ins_slit_wid		float null,
	ins_reta2_name		varchar(10) null,
	ins_reta2_posang	float null,
	ins_woll_name		varchar(10) null,
	ins_woll_posang		float null,
	ins_pixscale		float null,
	ins_lamp1_name		varchar(10) null,
	ins_lamp2_name		varchar(10) null,
	ins_lamp3_name		varchar(10) null,
	ins_lamp4_name		varchar(10) null,
	ins_lamp5_name		varchar(10) null,
	ins_lamp6_name		varchar(10) null,
	ins_lamp7_name		varchar(10) null,
	ins_lamp8_name		varchar(10) null,
	ins_lamp9_name		varchar(10) null,
	det_read_clock		varchar(10) null,
	det_out1_conad		float null,
	det_out2_conad		float null,
	det_out3_conad		float null,
	det_out4_conad		float null,
	det_outputs		tinyint null,
	det_win1_nx		smallint null,
	det_win1_ny		smallint null,
	det_win1_binx		tinyint null,
	det_win1_biny		tinyint null,
	det_win1_strx		smallint null,
	det_win1_stry		smallint null,
	tel_alt			float null,
	tel_az			float null,
	tel_dome_status		varchar(10) null,
	obs_targ_name		varchar(32) null,
	dimm_fwhm_avg		float null,
	dimm_fwhm_rms		float null,
	night_flag		tinyint null,
	moon_illu		smallint null
)

print "Creating indices on fors table"
go

create unique clustered index dp_id
	on fors ( dp_id )
go

grant select on fors to public
grant insert,update on fors to frameingest
go
