truncate

What is the command to truncate a SQL Server log file?

I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log? ...

MySql - Create Table If Not Exists Else Truncate?

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 error message on the truncate since the table doesn't exist yet. Is my only optio...

NHibernate nvarchar/ntext truncation problem

I'm using nhibernate to store some user settings for an app in a SQL Server Compact Edition table. This is an excerpt the mapping file: <property name="Name" type="string" /> <property name="Value" type="string" /> Name is a regular string/nvarchar(50), and Value is set as ntext in the DB I'm trying to write a large amount of xml to...

Truncate stdin line length?

I've been parsing through some log files and I've found that some of the lines are too long to display on one line so Terminal.app kindly wraps them onto the next line. However, I've been looking for a way to truncate a line after a certain number of characters so that Terminal doesn't wrap, making it much easier to spot patterns. I wro...

What is the correct LINQtoSQL-ish way to do a table truncate?

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 swimmingly until I needed to do a truncate on a table and all I had were “delete”...

mysql duplicate entry error when there is no duplicate entry (bulk load via php)

i am using mysql (5.0.32-Debian_7etch6-log) and i've got a nightly running bulk load php (5.2.6) script (using Zend_DB (1.5.1) via PDO) which does the following: truncating a set of 4 'import' tables bulk inserting data into these 4 'import' tables (re-using ids that have previously been in the tables as well, but i truncated the whole...

smart truncate in python?

I am looking for a way to do smart truncating in python. By this I mean that if a string is over X amount of characters then it will only show the first X characters and a suffix like '...'. By "smart" I mean that it will not cutoff words in the middle instead it will cut off on spaces. For instance, not "this is rea...", instead "this i...

Cannot truncate table because it is being referenced by a FOREIGN KEY constraint?

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 FK, truncate and recreate but I thought as long as you truncate the child table you...

Truncate Decimal number not Round Off

I want to truncate the decimals like below i.e. 2.22939393 -> 2.229 2.22977777 -> 2.229 ...

Why 'delete from table' takes a long time when 'truncate table' takes 0 time?

(I've tried this in MySql) I believe they're semantically equivalent. Why not identify this trivial case and speed it up? ...

Truncate Text at a Stop Character Match

How would I truncate a sentence at a certain character: $sentence = 'Stack Overflow - Ask Questions Here'; so that only the following is echoed: Stack Overflow The character count varies, but the stop point is always "Space Dash Space" ...

shell script to truncate all MySql tables

Hi, I'm looking for a Unix shell script that will truncate all tables in a schema. A similar question was already asked, but I have some additional requirements which makes none of the provided answers satisfactory: Must be a Unix shell script (i.e. no python, perl, PHP) The script must truncate the tables in an order which respects f...

Detecting that log file has been deleted or truncated on POSIX systems?

Suppose a long-running process writes to a log file. Suppose that log file is kept open indefinitely. Suppose that a careless system administrator deletes that log file. Can the program detect that this has happened? Is it safe to assume that fstat() will report a link count of zero for a deleted file? Truncation, it seems to me, is...

How to make a log as small as possible in a SQL database?

This question might be kind of elementary, but here goes: I have a SQL Server database with a 4 GB log file. The DB is 16GB and is backed up nightly. Can I truncate the log regularly because the entire DB+Log is backed up each night? ...

Truncate Slow Query Log in MySQL

What's the safest way to truncate the MySQL slow query log (under Linux primarily, but Windows would be handy to know) while MySQL is running? By safe I mean: Mustn't cause any permissions problems Mustn't jump back to its original size next time its appended to ...

How to generate a compiler warning/error when object sliced

Hello, Gurus, I want to know if it is possible to let compiler issue a warning/error for code as following: Note: 1. Yea, it is bad programming style and we should avoid such cases - but we are dealing with legacy code and hope compiler can help identify such cases for us.) 2. I prefer a compiler option (VC++) to disable or enable ob...

What is the best way to empty a self-referential MySQL table?

I have a self-referential MySQL table with a recursive parent_id: CREATE TABLE `recursive` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY `data_categorysource_parent_id` (`parent_id`), CONSTRAINT `parent_id_refs_id_627b4293` FOREIGN KEY (`p...

error while truncating tables from oracle db

I am doing something like this in a procedure to clear all data from all tables in my database. LOOP dbms_utility.exec_ddl_statement('alter table ' || c.owner || '.' || c.table_name || ' disable constraint ' || c.constraint_name); END LOOP; . . . LOOP EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || t.table_name ; END LOOP; Now ...

SQL group by "date" question

Hello. I'm trying to make a report but I'm having problems with my archi nemesis SQL. I have a table where the close date of a transaction is stored. I want to know how many transaction per month there was so I did: SELECT trunct( closedate, 'MONTH' ) FROM MY_TRANSACTIONS I'm using oracle. I'm getting a list like this: 2002-0...

Trim string to length ignoring HTML.

This problem is a challenging one. Our application allows users to post news on the homepage. That news is input via a rich text editor which allows HTML. On the homepage we want to only display a truncated summary of the news item. For example, here is the full text we are displaying, including HTML In an attempt to make a b...