下面这个贴子中讨论了很多access中的一些猜想假设。 access或其它数据库操作效率问题.欢迎讨论 http://topic.csdn.net/u/20090514/10/a93475bd-e67e-45c8-aa1e-87168ba36d02.html#replyachor 引用 55 楼 wwwwb 的回复:: create table是用什么方法?我一般是
下面这个贴子中讨论了很多access中的一些猜想假设。
access或其它数据库操作效率问题.欢迎讨论
http://topic.csdn.net/u/20090514/10/a93475bd-e67e-45c8-aa1e-87168ba36d02.html#replyachor
引用 55 楼 wwwwb 的回复::
create table是用什么方法?我一般是将空的工作表另存为一个临时表,
用select * into 工作表 from 临时表 方法建立,这种方法比delete from table
还要慢?
这种方法的局限是如果有表间关系是不能删除的。
当看到这个猜想的时候,感觉比较怀疑。因为 select * into newtable from oldtable,access需要先从oldtable得到所有字段的定义,然后才能进行表的创建。如果猜想成立,就说明access还有一套什么机制可以直接在底层对表的结构进行访问。但select 可以是任意的查询,这样也不太可能啊。 于是,依然做个简单的试验来难证一下这个猜想。
新建空 t.mdb ,然后创建一个模块,代码如下。
option compare databaseoption explicitpublic sub ti() dim ssql as string dim conn as adodb.connection set conn = currentproject.connection ssql = create table table2(id integer,cname char(10)) conn.execute ssql end subpublic sub tx() dim ssql as string dim conn as adodb.connection set conn = currentproject.connection dim i as integer on error resume next for i = 1 to 9000 ssql = drop table t & (10000 + i) currentproject.connection.execute ssql next i on error goto 0end subpublic sub t1() dim ssql as string dim i as integer for i = 1 to 9000 ssql = create table t & (10000 + i) & (id integer,cname char(10)) currentproject.connection.execute ssql next iend subpublic sub t2() dim ssql as string dim i as integer for i = 1 to 9000 ssql = select * into t & (10000 + i) & from table2 currentproject.connection.execute ssql next iend subpublic sub t() call tx debug.print t1 start., now call t1 debug.print t1 end ., now call tx debug.print t2 start., now call t2 debug.print t2 end ., nowend sub
步骤一:运行 ti()创建一个原表 table2 以供后面的 select * into newtable from oldtable 使用。
步骤二:运行 t() 结果如下。
t1 start. 5/23/2009 3:06:54 pm
t1 end . 5/23/2009 3:07:03 pm
t2 start. 5/23/2009 3:07:17 pm
t2 end . 5/23/2009 3:07:29 pm
t1() 9s , t2() 12s
试验结论: 猜想不成立。
