DROP TABLE语法 - 与Select一起使用? [英] DROP TABLE syntax - use with Select?

查看:885
本文介绍了DROP TABLE语法 - 与Select一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DROP TABLE语句可以与select或where语句一起使用吗?

DROP TABLE SELECT *

FROM tblTablesImported

WHERE Import_ID不在

(SELECT [Table_ID] FROM tblTablesInternal);


或者我必须提供如下参数:


DROP TABLE Sheet1


提前致谢。

解决方案

Deko,

那么,你只想转储特定的表?如同,只删除不是内部表的表

?嗯。 Dunno如何编写DROP语句

只删除一些表而不是其他人没有办法将它们分组

通过表空间或其他类似的成员资格。并且。 。 。我的特殊原因是b $ b习惯是构建临时表,将行添加到行中,在行上完成工作,然后单独留下直到下一次运行。那样的话,如果有什么事情发生的话,我可以至少看一下临时表中的行,看看我能不能确定发生了什么,也许可以纠正那些没有做过的工作

正确的方式。要做你想做的事我会倾向于写一些使用

ADODB.COMMAND对象的VBA和一个遍历表格列表的循环我想要丢弃的b $ b ,每次迭代动态生成我的DROP语句

并执行生成的命令。不是纯粹的SQL,但足够好。


" deko" <德** @ hotmail.com>在消息中写道

news:b2 ***************** @ newssvr13.news.prodigy.co m ...

DROP TABLE语句可以与select或where语句一起使用吗?

DROP TABLE SELECT *
FROM tblTablesImported
WHERE Import_ID不在
中(SELECT [Table_ID]来自tblTablesInternal);

或者我必须提供如下参数:

DROP TABLE Sheet1

提前致谢。



呵呵什么?你的意思是你有一张桌子(tblTablesImported),你想要

通过代码丢弃其中的一些?


嗯...开启一个前进的方法怎么样要删除的记录集


SELECT *

FROM tblTablesImported

WHERE Import_ID不在

( SELECT [Table_ID] FROM tblTablesInternal)


然后循环生成的记录集并做一些事情

就像


strSQL =" DROP TABLE [" &安培; rs.Fields(TableName)& "]"

currentdb.Execute strSQL,dbFailOnError

或其他一些东西......


>那么,你只想转储特定的表?如同,只删除不是内部表的表

?嗯。 Dunno如何编写一个DROP语句
只会丢弃一些表而不是其他人没有办法将它们分组,或者通过表空间中的成员资格或其他类似的表。并且。 。 。我的特殊习惯是构建临时表,将行添加到行中,在行上完成
,然后单独执行直到下一次运行。这样一来,如果出现问题,我至少可以查看临时表中的行,看看我是否能够辨别发生了什么,也许还可以纠正那些没有发生过的工作
正确的方式。为了做你想做的事,我倾向于写一些使用了ADODB.COMMAND对象的VBA和一个迭代通过我想要删除的表列表的循环,动态生成我的DROP语句每次
迭代并执行生成的命令。不是纯粹的SQL,但足够好。




TIMTOWTDI,当然。循环记录集的工作原理。如果我用bd用ddl执行它,它会很好。但是我不知道如何将选择和

语句与DROP或CREATE结合起来。


Can the DROP TABLE statement be used with a select or where statement?

DROP TABLE SELECT *
FROM tblTablesImported
WHERE Import_ID Not In
(SELECT [Table_ID] FROM tblTablesInternal);

Or do I have to supply a parameter like:

DROP TABLE Sheet1

Thanks in advance.

解决方案

Deko,
So, you only want to dump particular tables? As in, drop only the tables
that are not internal tables? Hmmm. Dunno how to write a DROP statement
that only drops some tables and not others without a way to group them
through membership in a tablespace or some such. And . . . my particular
habit is to build temporary tables that get rows added to them, work done on
the rows, then left alone until the next run. That way if something goes
awry I can at least look at the rows in the temp table to see if I can
discern what happened and also maybe correct the work that didn''t happen the
right way. To do what you want I''d tend to write some VBA that used an
ADODB.COMMAND object and a loop that iterated through a list of tables I
wanted dropped, generating my DROP statement on the fly with each iteration
and executed the generated command. Not purely SQL, but good enough.

"deko" <de**@hotmail.com> wrote in message
news:b2*****************@newssvr13.news.prodigy.co m...

Can the DROP TABLE statement be used with a select or where statement?

DROP TABLE SELECT *
FROM tblTablesImported
WHERE Import_ID Not In
(SELECT [Table_ID] FROM tblTablesInternal);

Or do I have to supply a parameter like:

DROP TABLE Sheet1

Thanks in advance.



huh what? You mean you have a table (tblTablesImported), and you want
to drop some of them through code?

Ummm... How about opening a forwardonly recordset of tables to drop

SELECT *
FROM tblTablesImported
WHERE Import_ID Not In
(SELECT [Table_ID] FROM tblTablesInternal)

and then looping through the resulting recordset and doing something
like

strSQL = "DROP TABLE [" & rs.Fields("TableName") & "]"
currentdb.Execute strSQL, dbFailOnError

or some such thing...


> So, you only want to dump particular tables? As in, drop only the tables

that are not internal tables? Hmmm. Dunno how to write a DROP statement
that only drops some tables and not others without a way to group them
through membership in a tablespace or some such. And . . . my particular
habit is to build temporary tables that get rows added to them, work done on the rows, then left alone until the next run. That way if something goes
awry I can at least look at the rows in the temp table to see if I can
discern what happened and also maybe correct the work that didn''t happen the right way. To do what you want I''d tend to write some VBA that used an
ADODB.COMMAND object and a loop that iterated through a list of tables I
wanted dropped, generating my DROP statement on the fly with each iteration and executed the generated command. Not purely SQL, but good enough.



TIMTOWTDI, for sure. looping through a recordset works. it wd be nice if I
cd do it with ddl. but I''m not sure how to combine select and where
statements with DROP or CREATE.


这篇关于DROP TABLE语法 - 与Select一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆