[英]How can we truncate table using the Grails domain or GORM?
I want to truncate my table named as scraper_proxies
.我想截断名为
scraper_proxies
的表。 I can truncate this table using the native SQL like below:我可以使用本机 SQL 截断此表,如下所示:
int truncateResult = session.createSQLQuery("TRUNCATE TABLE scraper_proxies").executeUpdate()
Requirement要求
But i want to truncate this table using the Grails domain named as ScraperProxies
which is mapped with scraper_proxies
table.但我想使用名为
ScraperProxies
的 Grails 域截断此表,该域与scraper_proxies
表映射。
Is anyone have any idea about it?有人对此有任何想法吗?
Delete all ScraperProxies
records in the database using the Grails domain :使用Grails 域删除数据库中的所有
ScraperProxies
记录:
Integer result = ScraperProxies.executeUpdate("delete ScraperProxies")
It will return the integer value.它将返回 integer 值。 If it deletes the 5 rows than return value will be 5.
如果删除 5 行,则返回值为 5。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.