Limit data input and reduced scope of some variables.

Signed-off-by: Shido <the.keikun@gmail.com>
SQL Re-Organization.

Signed-off-by: KeiKun <the.keikun@gmail.com>
Organized sql-tools.
Updated sql-upgrade files.