Presentation is loading. Please wait.

Presentation is loading. Please wait.

목차 SQL 표준 (ISO) SQL 실행 순서 및 명칭 부분 범위 처리 ( 다움기회에..) 인덱스 선정 ( 다음기회에..) DBMS 비교 최적화 데이터 설계 why sql learn??

Similar presentations


Presentation on theme: "목차 SQL 표준 (ISO) SQL 실행 순서 및 명칭 부분 범위 처리 ( 다움기회에..) 인덱스 선정 ( 다음기회에..) DBMS 비교 최적화 데이터 설계 why sql learn??"— Presentation transcript:

1

2 목차 SQL 표준 (ISO) SQL 실행 순서 및 명칭 부분 범위 처리 ( 다움기회에..) 인덱스 선정 ( 다음기회에..) DBMS 비교 최적화 데이터 설계 why sql learn??

3 SQL 표준 (ISO) YearNameAliasComments 1986SQL-86SQL-87First published by ANSI. Ratified by ISO in 1987.ANSIISO1987 1989SQL-89Minor revision. 1992SQL-92SQL2Major revision (ISO 9075). 1999SQL:1999SQL3Added regular expression matching, recursive queries, triggers, non- scalar types and some object-oriented features. (The last two are somewhat controversial and not yet widely supported.) 2003SQL:2003 Introduced XML-related features, window functions, standardized sequences and columns with auto-generated values (including identity-columns).XML 2006SQL:2006 ISO/IEC 9075-14:2006 defines ways in which SQL can be used in conjunction with XML. It defines ways of importing and storing XML data in an SQL database, manipulating it within the database and publishing both XML and conventional SQL-data in XML form. In addition, it provides facilities that permit applications to integrate into their SQL code the use of XQuery, the XML Query Language published by the World Wide Web Consortium (W3C), to concurrently access ordinary SQL-data and XML documents.XQueryW3C

4 SQL 실행 순서 및 명칭 SQL SELECT 이름, ( SELECT count(*) FROM 가족 B WHERE A. 사원번호 = B. 사원번호 ) 가족수, 봉급 FROM ( SELECT 이름, SAL, 부서번호 FROM 사원 WHERE SAL > 200 ) A WHERE 부서번호 IN ( SELECT 부서번호 FROM 부서 WHERE 부서명 = ‘ 개발팀 ’); 스칼라서브 쿼리 inline view nested sub query main query

5 툴을 사용한 실행 계획 nested subquery inline view 스칼라 서브 쿼리

6 sqlplus id/pwd sqlplus>set autotrace on

7 SQL Server 2000 vs MySQL 4.1 FeatureT-SQL MySQL dialect Views General Views, Indexed Views, Distributed Partitioned Views Not Supported Triggers AFTER triggers, INSTEAD OF triggers Not Supported Stored Procedures T-SQL statements Not Supported User-defined functions Scalar functions, Inline table-valued functions, Multistatement table-valued functions C, C++ external libraries Foreign KeysSupported Supported for only InnoDB tables CursorsSupported Not Supported ArraysNot SupportedSupported Feature SQL Server 2000 MySQL v4.1 column name length12864 index name length12864 table name length12864 max indexes per table25032 index length9001024 max index column length900255 columns per index16 max char() size80001048543 max varchar() size80001048543 max blob size21474836471048543 max number of columns in GROUP BY Limited on ly by numb er of bytes (8060) 64 max number of columns in ORDER BY Limited on ly by numb er of bytes (8060) 64 tables per SELECT statement25631 max columns per table10242599 max table row length803665534 longest SQL statement167772161048574 constant string size in SELECT167772071048565 SQL Server 2000 and MySQL v4.1 limits Features comparison

8 SQL Server 2000 vs Oracle 9i FeaturePL/SQLT-SQL Indexes B-Tree indexes, Bitmap indexes, Partitioned indexes, Function-based indexes, Domain indexes B-Tree in dexes Tables Relational tables, Object tables, Temporary tables, Partitioned tables, External tables, Index organized tables Relationa l tables, Temporar y tables Triggers BEFORE triggers, AFTER triggers, INSTEAD OF triggers, Database Event triggers AFTER tri ggers, INSTEAD OF trigge rs Procedures PL/SQL statements, Java methods, third-generation language (3GL) routines T-SQL sta tements ArraysSupported Not Supp orted Feature SQL Serve r 2000 Oracle 9i Database database name length1288 column name length12830 index name length12830 table name length12830 view name length12830 stored procedure name length12830 max columns per index1632 max char() size80002000 max varchar() size80004000 max columns per table10241000 max table row length8036255000 max query size16777216 recursive subqueries4064 constant string size in SELECT167772074000 constant string size in WHERE80004000 Features comparisonSQL Server 2000 and Oracle 9i limits

9 최적화 1.OS 자 원의 튜 닝 2. 인스턴스 튜닝 3. 어플리케이션의 튜닝 4. 오브젝트의 튜닝 5.SQL 튜닝 6.DB 설계 변경 ( 튜닝 ) 7.Architecture 변경 SE DBA 개발자, SE DBA, 개발 자 DBA DBA, 개발 자 개발자, DBA, SE

10 Architectue 변경 apache + shared server tomcat + dedicated server why???

11 MS-SQL 의 최적화 설계 CREATE TABLE BBS_T ( NAME varchar (10) NULL, EMAIL varchar (100) NULL, SUBJECT varchar (100) NOT NULL, CONTENT text NOT NULL, REGI_DATE smalldatetime NOT NULL, IP varchar (15) NOT NULL, CNT int NOT NULL, GROUP_ID int NOT NULL, DEPTH int NULL, GROUP_ORDER int NOT NULL ) ON [PRIMARY] GO CREATE UNIQUE CLUSTERED INDEX PK_BBS_T ON dbo.BBS2_T (GROUP_ID DESC, GROUP_ORDER ASC) GO

12 Stored Procedure 사용 CREATE PROCEDURE dbo.BBS_LST_P @listsize int,@gotopage int,@recordcnt int output,@pagecnt int output AS begin declare @sql nvarchar(1000), @num int, @total int -- 레코드갯수 얻기 SELECT @recordcnt = COUNT(GROUP_ID) FROM BBS_T (NOLOCK) -- 페이지 갯수 얻기 if @recordcnt = 0 set @pagecnt = 1 else set @pagecnt = (@recordcnt-1)/@listsize + 1 if @gotopage > @pagecnt set @gotopage = @pagecnt if @gotopage < @pagecnt set @total=@listsize else set @total=@recordcnt - (@gotopage-1)*@listsize set @num=@gotopage*@listsize set @sql=' SELECT NAME, EMAIL, SUBJECT, REGI_DATE, CNT, GROUP_ID, GROUP_ORDER, DEPTH FROM ( SELECT TOP '+ltrim(str(@total)) +' NAME, EMAIL, SUBJECT, REGI_DATE, CNT, GROUP_ID, GROUP_ORDER, DEPTH FROM ( SELECT TOP '+ltrim(str(@num)) +' NAME, EMAIL, SUBJECT, REGI_DATE, CNT, GROUP_ID, GROUP_ORDER, DEPTH FROM BBS_T (NOLOCK) ) AS D2 ORDER BY GROUP_ID ASC, GROUP_ORDER DESC ) AS D1 ORDER BY GROUP_ID DESC, GROUP_ORDER ASC' exec sp_executesql @sql end

13 오라클 최적화 설계 create table BOARD ( AID NUMBER(38) not null, BID NUMBER(7) not null, TITLE VARCHAR2(300) not null, CONTENT CLOB, REGDATE DATE not null, REGIP VARCHAR2(15) not null, PAID NUMBER(38) not null, PPAID NUMBER(38) not null, PPORDER NUMBER(10) not null, ALEVEL NUMBER(10) not null, VCNT NUMBER(10) default 0, ) create unique index BOARD_FBI1 on BOARD (LPAD(TO_CHAR(BID),4,'0')||LPAD(TO_CHAR(PPAID),9,'0')||TO_CHAR(99999-PPORDER))

14 why sql learn?? 돈이 된다. 삶을 윤택하게 …( 개발시간감소, 서 버 안죽음 ㅡ. ㅡ ) 배우기 쉽다.

15 참고자료 http://www.ihelpers.co.kr/programming/index.php?A G=pg http://www.ihelpers.co.kr/programming/index.php?A G=pg http://www.en-core.com/ 대용량 데이터 베이스 솔루션 1 권 새로쓴 대용량 데이터 베이스 솔루션 Perfect! 오라클 실전 튜닝 http://www.mssqlcity.com/Articles.htm


Download ppt "목차 SQL 표준 (ISO) SQL 실행 순서 및 명칭 부분 범위 처리 ( 다움기회에..) 인덱스 선정 ( 다음기회에..) DBMS 비교 최적화 데이터 설계 why sql learn??"

Similar presentations


Ads by Google