sql for indices/seqs