|
List the differences between the following MySql commands.
drop table tablename ; truncate table tablename ; delete from tablename where 1; Also from your experiences please tell me typical usage scenario for each.
Started by gameover on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
truncate table tablename; After this, the table is empty, and (importantly) auto-incrementing keys drop and ....
I would drop the table if I didn't need it anymore "Truncate operations.
Drop is deleting the table.
|
|
I have some tables that I build as a part of my report rollup. I don't need them afterwards at all. Someone mentioned to truncate them as it would be faster.
Started by Brian G on
, 14 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
truncate removes all the rows, but not the table itself, it is essentially equivalent to deleting the definition....
TRUNCATE TABLE empties it, but leaves its structure for future data.
DROP TABLE deletes the table.
|
|
What is the recommended way to truncate a table using hibernate/hql?
I've tried this:
Query query = session.createQuery("truncate table MyTable"); query.executeUpdate();
But it didn't work (truncate doesn't seem do be documented anywhere in hql...)
Answer Snippets (Read the full thread at stackoverflow):
* @throws DAOException */ public int truncate() throws DAOException { Session s = getSession ( HibernateException....
truncate table MyTable").executeUpdate();
Needless to say, this is not ideal in terms of portability from the targetted file.
|
Ask your Facebook Friends
|
Using MSSQL2005, Can I truncate a table with a foreign key constraint if I first truncate the child table(the table with the primary key of the FK relationship)?
I know I can use a DELETE without a where clause and then RESEED the identity OR
Remove the...
Started by ctrlShiftBryan on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The last step will fail, because TRUNCATE TABLE....
If you go through the process of "drop FK, truncate table, create FK".
Typically my process.
Correct; you cannot truncate a table which has an FK constraint on it.
|
|
I want to truncate the TVP instead of DROPPING.
When I am writing TRUNCATE TYPE it is giving error.
DROP TYPE is working but iI want TRUNCATE
Can any one help me with the syntax?
thank you
Started by VinnaKanna on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
To modify the data that is passed to a stored procedure or parameterized... .
Into a temporary table and then truncate that, but I'm not sure what use that would be!
In SQL Server 2008, a Table Valued Parameter is ReadOnly in the TSQL code.
|
|
Here is the updated question:
the current query is doing something like:
$sql1 = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu";
The first time the method containing this is run, it generates an...
Started by shmuel613 on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
CREATE TABLE fubar IF NOT EXISTS TRUNCATE TABLE = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu....
And always be empty at that point.
It will always exist...
|
|
Can the SQL "truncate table" command be used within a transaction? I am creating an app and my table has a ton of records. I want to delete all the records, but if the app fails I was to rollback my transaction. Deleting each record takes a very long ...
Started by Fred Clown on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In SQL Server, you can rollback....
PostgreSQL, MySQL, SQL Server, Oracle, etc.
In Oracle, TRUNCATE TABLE of the behaviour of TRUNCATE TABLE.
It does write page deallocation to the log, as you mentioned .
From a transaction.
|
|
I have a project with a formidable data access layer using LinqtoSQL for just about anything touching our databases. I needed to build a helper class that bridges some common crud operations from CLSA objects to LinqToSql ones. Everything has been operating...
Started by Ian Patrick Hughes on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
This:
yourDataContext.ExecuteCommand("TRUNCATE TABLE YourTable");
a stored procedure that truncates the table, and then call the procedure from LINQ, but that isn't.
|
|
Is there a query (command) to truncate all the tables in a database in one operation? I want to know if I can do this with one single query.
Started by devang on
, 7 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Here is how you would call TRUNCATE TABLE with this stored procedure:
EXEC [sp_MSforeachtable] @command1="TRUNCATE TABLE ?"
Here is a good PRINT for actual ....
Or a set of commands against all tables inside a database.
|
|
(I've tried this in MySql)
I believe they're semantically equivalent. Why not identify this trivial case and speed it up?
Started by ripper234 on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Truncate effectively drops the table and recreates table....
...just to add, and if there are any foreign key constraints (for innodb) .
truncate table cannot be rolled back, it is like dropping and recreating the table.
|