fixed bug, and modify sql files according to spec