UNIX sequential execution of files -
i want sequentially execute .sqls in directory in unix .
suppose directory name /export/home/me when list files in directory using ls shows
a.sql b.sql c.sql
now , need write shell script go directory , loop through .sqls in directory , execute them sequentially .please suggest
if sequential, mean sorted alphabetically, this,
#!/bin/sh in `ls folder/*.sql | sort ` # think shell lists file sorted alphabetically default mysql -u user_name -ppassword database_name < done
but, when executing list of sql files, need think of order, example, if design is,employees , departments, if first sql file creates employees table , second sql file creates foreign key departments table, before executing third sql file creates departments table, run trouble.
its best have create/insert statments of database objects/data in 1 sql file in right order.
Comments
Post a Comment