SQL TRUNCATE DATABASE ? How to TRUNCATE ALL TABLES

You can use the sp_MSforeachtable stored procedure like so: USE MyDatabase EXEC sp_MSforeachtable ‘TRUNCATE TABLE ?’ Be warned that this will delete (by truncation) ALL data from all user tables. And in case you can’t TRUNCATE due to foreign keys etc. you can run the same as a delete: USE MyDatabase EXEC sp_MSforeachtable ‘DELETE FROM … Read more

Gremlin remove all Vertex

In more recent terms as of Gremlin 2.3.0, removal of all vertices would be best accomplished with: g.V.remove() UPDATE: For version Gremlin 3.x you would use drop(): gremlin> graph = TinkerFactory.createModern() ==>tinkergraph[vertices:6 edges:6] gremlin> g = graph.traversal() ==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard] gremlin> g.V().drop().iterate() gremlin> graph ==>tinkergraph[vertices:0 edges:0] Note that drop() does not automatically iterate the Traversal … Read more

MySQL: Truncate Table within Transaction?

http://dev.mysql.com/doc/refman/5.1/en/truncate-table.html According to this URL, as of MySQL 5.1.32, TRUNCATE TABLE is DDL and NOT DML like DELETE. This means that TRUNCATE TABLE will cause an implicit COMMIT in the middle of a transaction block. So, use DELETE FROM on a table you need to empty instead of TRUNCATE TABLE. Even DELETE FROM tblname; can … Read more

Truncate a string without ending in the middle of a word

I actually wrote a solution for this on a recent project of mine. I’ve compressed the majority of it down to be a little smaller. def smart_truncate(content, length=100, suffix=’…’): if len(content) <= length: return content else: return ‘ ‘.join(content[:length+1].split(‘ ‘)[0:-1]) + suffix What happens is the if-statement checks if your content is already less than … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)