|
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.
|
|
I have a Microsoft SQL Server 2008 with many databases and most of them have a Logs table. I would like to be able to schedule a script to run and truncate the Logs table in every one of these databases (dynamically). I imagine I have to get the name ...
Started by notandy on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Use ?; TRUNCATE TABLE Logs'
In 2008 the easiest thing to do if if its not in production use.
|
|
Do we need to Update table statistics after calling Truncate table or it gets updated automatically?
Q: Do we need to call "UPDATE STATISTICS" after truncating a table?
Started by noob.spt on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Stats are not automatically updated until, not the INSERT, DELETE or TRUNCATE
IF OBJECT_ID('dbo.foo') IS NOT NULL DROP TABLE dbo.foo CREATE TABLE) AS After2ndQuery....
Ust truncate and then update the stats on the table.
|
|
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.
|