Windows DB

SQL System Query

2009.05.14 18:55

dalgri 조회 수:13305

 

보통 적으로 많이 사용하는 쿼리들 입니다.

 

--System table Query

select * from sysobjects where xtype='u'


--Table size
select  table_name = convert(varchar(30), min(o.name)), table_size = ltrim(str(sum(reserved) *8192/1024,15,0) + 'kb'),crdate,refdate
from sysindexes i inner join sysobjects o on (o.id = i.id)
where i.indid in (0,1,255) and o.xtype = 'U'
group by i.id,crdate, refdate
order by refdate desc


--Table PK 기본키
select name  from sysobjects where xtype ='pk'

 


--Table name

select x.id, substring(y.name,1,30) as [table], substring(x.name,1,30)
as field_name, substring(type_name(x.xusertype),1,20) as type,
convert(int,x.length) as length
from syscolumns x inner join
 sysobjects y on x.id = y.id
where (y.type='U')
order by x.id, y.name, x.colid

-- Columns
select * from syscolumns


--Table Field
sp_helpindex s_member_tbl


--# 참고 Sysobjects
select * from sysobjects

번호 제목 글쓴이 날짜 조회 수
50 DBConnectionOpen오류 호스트웨이 2012.07.14 6367
49 Windows Server2008 에서 MSSQL2005 Reporting Service 설치하기 file 호스트웨이 2012.03.09 6531
48 MS-SQL 서버 메모리 사용량 제한 호스트웨이 2012.12.14 7287
47 [MS SQL]트랜잭션 사용 호스트웨이 2015.09.15 7414
46 DB 마이그레이션 방법 호스트웨이 2012.04.27 7421
45 mssql-table backup(테이블 백업/복원) 호스트웨이 2015.09.09 8725
44 [MSSQL]인덱스 (INDEX) 사용하기 호스트웨이 2015.09.16 8745
43 DB 소유권 이전 호스트웨이 2012.06.01 8859
42 MSSQL Express Backup 자동화 file 호스트웨이 2015.05.06 8870
41 [MSSQL] 다른 테이블로 데이터 INSERT 호스트웨이 2015.09.16 8980
40 MSSQL Master DB 이동 file 호스트웨이 2012.05.11 9432
39 DBMS효율적으로 관리하기 - LDF 축소 호스트웨이 2012.05.11 9603
38 SQL2008 설치시 성능 카운터 레지스트리 하이브 일관성 실패 file 호스트웨이 2012.07.14 10045
37 mssql 백업파일 내의 MDF,LDF 이상 확인 호스트웨이 2015.09.18 10089
36 [MS SQL]ssms 단축키 호스트웨이 2015.09.15 10462
35 데이터베이스 경로 변경하기 (MDF,LDF파일 경로 변경하기) 호스트웨이 2012.11.15 10677
34 SQL 서버 인증모드 변경 file 호스트웨이 2012.04.20 10694
33 MSSQL DB Lock 해제 file 호스트웨이 2012.06.23 10892
32 MDF, LDF 파일 복사하는 방법 호스트웨이 2015.09.18 11236
31 MS SQL 2008에서 메뉴 관리툴의 한글깨짐 현상 방지 file 호스트웨이 2012.03.16 11268