Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Friday, July 22, 2011

MS SQL Server - Clear Cache - for Query Timing

[Using MS-SQL Server] When timing a query for the purposes of optimization, the query may well run quicker on re-execution subsequent to the initial execution - due to caching by the db engine.

In order to meaningfully compare execution time across optimization attempts, the cache needs to be cleared, and this can be done by executing


DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
go


between query timings.

To turn query timing on - SET STATISTICS TIME ON
To turn query timing off - STATISTICS TIME OFF

Saturday, January 22, 2011

Export Create Table Script in mySQL

SHOW CREATE TABLE TableName;

Thursday, October 21, 2010

Useful DataBase MetaData Scripts

1. given a column name, return a list of tables with similar columns names

declare @targetColumnName varchar(500)
set @targetColumnName = '%YourTargetColumnNameHere%'

select so.[name] as TableName, sc.[name] as ColumnName
from sysobjects so
inner join syscolumns sc on (so.[id] = sc.[id])
where (so.[type] = 'U') and (sc.[name] like @targetColumnName)


2. given a table name, return a list of tables with similar name

declare @targetTableName varchar(500)
set @targetTableName = '%Entity%'

select so.[name] as TableName
from sysobjects so
where (so.[type] = 'U') and (so.[name] like @targetTableName)

Wednesday, July 21, 2010

Monday, July 19, 2010

Untangling Object Dependencies in MS-SQL-08

useful TechRepublic Blog

1. get a list of all system objects from sys.objects
name,object_id,parent_object_id,type

2. determine individual dependencies from sys.sql_dependencies
object_id, referenced_major_id

3. use a topological sort to untangle the list of dependencies to a simple dependency tree.

Saturday, June 20, 2009

Setting up a mySQL DataBase on uBuntu

http://www.debuntu.org/how-to-create-a-mysql-database-and-set-privileges-to-a-user

'import MySQLdb' failed

http://davidmichaelthompson.com/?p=12

duh, need to install package 'python-mysqldb', 'A Python interface to mySQL'.