get table names with database prefix

When database has a prefix it doesnt work, now added tablenames with prefix