select * from table1 where name= '小王' union all select * from table2 where name= '小王' union all select * from table3 where name= '小王' union all .... union all select * from table10000 where name= '小王'
[解决办法] 能有这样的需求 就不要考虑性能问题了。 遍历表名,遍历出此表的所有列名, 查询 select * from table where col1 =' 小王' 拼接SQL 吧 [解决办法] 传说中的全文索引是如何索引的?
另外,感觉你这个需求有问题,一般不会有这么变态的需求吧,
看看变通一下吧,
如果程序也不会写,SQL语句也不会,那就没办法了,
[解决办法] 我是菜鸟。我说一下我的理解: 为什么非要一次执行呢。 你9万张表可以化大为小,执行时以10张表(或者更多张表)为单位查询,将每次返回结果存储到一个表中; 这样效率肯定会快; [解决办法] select * from table1 where name= '小王' union all select * from table2 where name= '小王' union all select * from table3 where name= '小王' union all .... union all select * from table10000 where name= '小王'
declare @str varchar(100) set @str='郑州南阳S-1N001' --要搜索的字符串
declare @s varchar(8000) declare tb cursor local for
select s='if exists(select 1 from ['+b.name+'] where ['+a.name+'] like ''%'+@str+'%'') print ''所在的表及字段: ['+b.name+'].['+a.name+']''' from syscolumns a join sysobjects b on a.id=b.id where b.xtype='U' and a.status>=0 and a.xusertype in(175,239,231,167) open tb fetch next from tb into @s while @@fetch_status=0 begin exec(@s) fetch next from tb into @s end close tb deallocate tb
这里存存储过程吧,oracle应该也提供全库检索功能.查查资料. [解决办法] select * from table1 where name= '小王' union all select * from table2 where name= '小王' union all select * from table3 where name= '小王' union all .... union all select * from table10000 where name= '小王'