DEFINITIONS

Definitions More Info.
Definition ID227
TitleSQL
CategorySCRIPT
DefinitionTUM TABLOLARDAKI KAYIT SAYISI
Definition Description--HANGI DATABASEDEKI TABLOLARIN KAYIT SAYILARINA BAKACAKSANIZ,O DATABASE DE CONNECTION OLSUN --ONCE BIRDEFAYA MAHSUS DBAllTblRowCount TABLOSU OLUSTURULUR /* USE [DATABASE] GO USE [DATABASE] GO /****** Object: Table [dbo].[DBAllTblRowCount] Script Date: 08/06/2012 15:22:57 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[DBAllTblRowCount]( [ID] [int] IDENTITY(1,1) NOT NULL, [RowNumber] [int] NULL, [TableName] [varchar](39) NOT NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO */ --SONRA TUM TABLOLARIN COUNTLARI ICIN ASAGIDAKI SORGU CALISTIRILIR. --CIKAN SONUC SQL SORGUSU OLUSTURUR. --BU SONUC CALISTIRILINCA TUM TABLOLARIN ROW COUNTLARI DBATblRowCount TABLOSUNA ATILIR SELECT 'INSERT INTO DBAllTblRowCount'+CHAR(13)+CHAR(10)+' SELECT COUNT (*) as RowNumber,'+''''+name+''''+'as TableName FROM '+name+' WITH (NOLOCK)'+CHAR(13)+CHAR(10)+' WAITFOR DELAY ''00:00:02''' FROM sys.tables --INDEXLER VE PRIMARY KEY EKLENIR /* /****** Object: Index [PK_DBAllTblRowCount] Script Date: 08/06/2012 15:21:24 ******/ ALTER TABLE [dbo].[DBAllTblRowCount] ADD CONSTRAINT [PK_DBAllTblRowCount] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY] GO /****** Object: Index [DBA_DBAllTblRowCount_RowNumber_201208061412] Script Date: 08/06/2012 14:13:48 ******/ CREATE NONCLUSTERED INDEX [DBA_DBAllTblRowCount_RowNumber_201208061412] ON [dbo].[DBAllTblRowCount] ( [RowNumber] DESC ) INCLUDE ( [ID], [TableName]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY] GO */ --SONRA ON MILYONDAN BUYUK TABLOLAR SIRALANIR SELECT * FROM DBAllTblRowCount WHERE RowNumber>10000000 --AND name not like '%log%' ORDER BY RowNumber DESC --select count(*) from DBAllTblRowCount --truncate table DBAllTblRowCount --drop table DBAllTblRowCount
RecordBycunay
Record Date06-08-2012 13:52:36
Düzenle
Kopyala
Sil