캠핑과 개발


MySQL Administrator 을 사용하여 데이터베이스를 생성하는 법을 알아본다.
만약 프로그램이 설치 되니 않았다면 해당 사이트에서 다운받아서 설치해야 한다.

http://dev.mysql.com/downloads/

먼저 프로그램을 실행 시키고 새로운 스키마를 생성을 한다.

1. 스키마 생성



스키마가 생성이 되었다면 새로운 스키마에 접근할수 있는 사용자를 추가한다.

2. 사용자 추가



2-1 사용자 계정 입력

Apply changes를 눌러 적용 시켜준다.

사용자가 추가 되었다면 추가된 사용자에 대한 권한을 준다.

Available Privileges에 있는 목록을 Assigned Privileges로 추가해준다.

3. 권한 부여




Apply changes를 눌러 적용 시켜준다.

여기까지가 완료 되었다면 Tools > MySQL Query Browser를 실행한다.



MySQL Query Browser 창이 뜨면 접속 권한을 설정해줘야 한다.
우측에 있는 스키마 창에서 mysql 탭을 더블 클릭한다.
선택이 되었다면 상단 창에 해당 선택된 스키마가 표시된다 제대로 선택이 되었는지 확인 후에
사용자에 대한 스키마 권한을 줘야 한다.

다음 쿼리를 실행해 준다.
  
grant all privileges on 디비명.* to 사용자이이디@localhost identified by '암호';
flush privileges;
select host, user, password from user order by user, host;




모두 완료 되었다면 클리이언트 프로그램으로 접속이 되는지 확인 해 본다.

'DEVELOPMENT > Database' 카테고리의 다른 글

[mysql] 날짜 관련 함수  (0) 2010.03.18
[mysql] 문자열 함수[펌]  (0) 2010.03.16
[Mysql] SQLyog GUI Tool  (0) 2009.10.28
리눅스에서 Mysql 5.1 컴파일하는 방법  (0) 2009.10.24
[mysql] 상위 5개 랜덤하게 가져오기  (0) 2009.10.06

리눅스상에서도 대부분 rpm버전을 깔 수 있지만 특수한 경우 mysql을 컴파일해야만 할 때가 있다.
다음과 같은 절차로 컴파일하면 된다.

1. mysql홈페이지에서 mysql 소스 다운(tar.gz파일)

2. 압축을 해제하고 그 디렉토리에서 ./configure 실행
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --sysconfdir=/etc --without-debug --with-charset=utf8 --with-extra-charsets=all --with-plugins=innobase
   --prefix : 설치될 경로
   --localstatedir : 디비파일이 설치될 경로
   --sysconfdir : 환경설정파일이 저장될 경로
   --without-debug : 디버그옵션 off 로 성능 향상
   --with-plugins=innobase : 트랜잭션사용을 위해 innobase 선택

3. make

4. make install

5. 기본 테이블을 만들어주는 스크립트 실행
/usr/local/mysql/bin/mysql_install_db

6. 데몬 실행
/usr/local/mysql/bin/mysqld_safe &
 - 이때 다음과 같은 에러가 발생하고 데몬이 뜨지 않으면 chown -R mysql.mysql /usr/local/mysql 명령을 실행후 다시 데몬을 시작한다.
14:46:27 mysqld_safe Logging to '/usr/local/mysql/var/localhost.localdomain.err'.
090520 14:46:27 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
090520 14:46:27 mysqld_safe mysqld from pid file /usr/local/mysql/var/localhost.localdomain.pid ended

7. innodb형식으로 테이블 생성
트랜잭션을 사용하기 위해 테이블생성시 다음과 같이 INNODB옵션을 준다.
CREATE TABLE Temp( col1 varchar(10) not null,
                                        col2 varchar(10)) TYPE=INNODB;



(select * from Table limit 0,5) order by rand()


출처 : http://web.lge.cn:8000/system/mysql/2059/page/2

'DEVELOPMENT > Database' 카테고리의 다른 글

[Mysql] SQLyog GUI Tool  (0) 2009.10.28
리눅스에서 Mysql 5.1 컴파일하는 방법  (0) 2009.10.24
mysql 최근 자료 가져오기  (0) 2009.10.06
[oracle] 자주 쓰는 숫자 함수  (0) 2009.09.27
Multi Table Insert  (0) 2009.07.14

최근 5일 자료를 가져오기 위한 쿼리

ex))
mysql> SELECT col1, col2, col3 FROM table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_column) <= 5;



/*
MOD 
나머지를 구한다.

표현식 : MOD(m, n)
설명 : m을 n으로 나누었을 때 나머지를 반환한다.
*/
SELECT MOD (10, 3) "Modulus"
  FROM DUAL 

--> 1 


/*
Round
반올림한 결과를 반환한다.

표현식 : Round(m, n)
설명 : m을 소숫점 n+! 자리에서 반올림한 결과를 반환한다.
       m이 양수이면 소숫점이 우측으로, 음수이면 좌측으로 이동한다.
 */
SELECT ROUND (18.364, 2) "Round"
  FROM DUAL
 
--> 18.36


SELECT ROUND (16.354, -1) "Round"
  FROM DUAL
 
--> 20


/*
WIDTH_BUCKET

표현식 : WIDTH_BUCKET(expr, min_value, max_value, num_buckets)
설명 : 어떤값의 최소에서부터 최대값을 설정하고 bucket을 지정하여 임의의
      값이 지정된 범위 내에서 어느 위치에 있는지를 반환한다.
*/
SELECT WIDTH_BUCKET (80, 0, 150, 10) "Score"
  FROM DUAL
 
--> 6

/*
CEIL

표현식 : CEIL(n)
설명 : 소숫점일 경우 반올림에 상관없이 올림 후 정수를 반환
*/
SELECT CEIL (12.1)
  FROM DUAL

--> 13


/*
FLOOR

표현식 : FLOOR(n)
설명 : 소숫점일 경우 반올림에 상관없이 내림 후 정수 반환
*/
SELECT FLOOR (12.9)
  FROM DUAL

--> 12

/*
ABS

표현식 : ABS(n)
설명 : 절대값을 반환한다.
*/
SELECT ABS (-12.9)
  FROM DUAL

--> 12.9

/*
ABS

표현식 : ABS(n)
설명 : 절대값을 반환한다.
*/
SELECT TRUNC (1.235, 2)
  FROM DUAL

--> 1.23

문법
INSERT [ALL/FIRST]
        WHEN 조건1 THEN
            INTO 테이블1
        WHEN 조건2 THEN
            INTO 테이블2
        ELSE
      INTO 테이블0
      SELECT 구문;


예제
INSERT ALL
   WHEN TO_CHAR (order_date, 'YYYY') = '1990'
   THEN
      INTO order_1990
   WHEN TO_CHAR (order_date, 'YYYY') = '1991'
   THEN
      INTO order_1991
   WHEN TO_CHAR (order_date, 'YYYY') = '1992'
   THEN
      INTO order_1992
   SELECT order_id, order_date, customer_id, order_total, sales_rep_id
     FROM orders;

CREATE TABLE order_1990 (
    order_id        NUMBER(12),
    order_date      DATE,
    customer_id     NUMBER(6),
    order_total     NUMBER(8, 2),
    sales_rep_id    NUMBER(6)
   );

CREATE TABLE order_1999 AS SELECT * FROM order_1990;
CREATE TABLE order_2000 AS SELECT * FROM order_1990;
CREATE TABLE order_2001 AS SELECT * FROM order_1990;


'DEVELOPMENT > Database' 카테고리의 다른 글

[oracle] 자주 쓰는 숫자 함수  (0) 2009.09.27
Multi Table Insert  (0) 2009.07.14
ER-Win에서 DB Table 가져오기  (0) 2009.05.13
MSSQL2000, 2005 테이블 명세서 추출 쿼리문  (0) 2009.05.13
oracle 시작과 종료  (0) 2009.05.07


ER-Win에서 ERD 작성을 하다보면 기존 DB에서 테이블 정보를 가져와야 할 때가 있다.

Tools > Reverse Engineer


--//SQL Database documentation script
--//Description: T-SQL script to generate the database document for SQL server 2000/2005

Declare @i Int, @maxi Int
Declare @j Int, @maxj Int
Declare @sr int
Declare @Output varchar(4000)
--Declare @tmpOutput varchar(max)
Declare @SqlVersion varchar(5)
Declare @last varchar(155), @current varchar(255), @typ varchar(255), @description varchar(4000)

create Table #Tables  (id int identity(1, 1), Object_id int, Name varchar(155), Type varchar(20), [description] varchar(4000))
create Table #Columns (id int identity(1,1), Name varchar(155), Type Varchar(155), Nullable varchar(2), [description] varchar(4000))
create Table #Fk(id int identity(1,1), Name varchar(155), col Varchar(155), refObj varchar(155), refCol varchar(155))
create Table #Constraint(id int identity(1,1), Name varchar(155), col Varchar(155), definition varchar(1000))
create Table #Indexes(id int identity(1,1), Name varchar(155), Type Varchar(25), cols varchar(1000))

 If (substring(@@VERSION, 1, 25 ) = 'Microsoft SQL Server 2005')
   set @SqlVersion = '2005'
else if (substring(@@VERSION, 1, 26 ) = 'Microsoft SQL Server  2000')
   set @SqlVersion = '2000'
else
   set @SqlVersion = '2005'


Print '<head>'
Print '<title>::' + DB_name() + '::</title>'
Print '<style>'
   
Print '      body {'
Print '      font-family:verdana;'
Print '      font-size:9pt;'
Print '      }'
     
Print '      td {'
Print '      font-family:verdana;'
Print '      font-size:9pt;'
Print '      }'
     
Print '      th {'
Print '      font-family:verdana;'
Print '      font-size:9pt;'
Print '      background:#d3d3d3;'
Print '      }'
Print '      table'
Print '      {'
Print '      background:#d3d3d3;'
Print '      }'
Print '      tr'
Print '      {'
Print '      background:#ffffff;'
Print '      }'
Print '   </style>'
Print '</head>'
Print '<body>'

set nocount on
   if @SqlVersion = '2000'
      begin
      insert into #Tables (Object_id, Name, Type, [description])
         --FOR 2000
         select object_id(table_name),  '[' + table_schema + '].[' + table_name + ']', 
         case when table_type = 'BASE TABLE'  then 'Table'   else 'View' end,
         cast(p.value as varchar(4000))
         from information_schema.tables t
         left outer join sysproperties p on p.id = object_id(t.table_name) and smallid = 0 and p.name = 'MS_Description'
         order by table_type, table_schema, table_name
      end
   else if @SqlVersion = '2005'
      begin
      insert into #Tables (Object_id, Name, Type, [description])
      --FOR 2005
      Select o.object_id,  '[' + s.name + '].[' + o.name + ']',
            case when type = 'V' then 'View' when type = 'U' then 'Table' end, 
            cast(p.value as varchar(4000))
            from sys.objects o
               left outer join sys.schemas s on s.schema_id = o.schema_id
               left outer join sys.extended_properties p on p.major_id = o.object_id and minor_id = 0 and p.name = 'MS_Description'
            where type in ('U', 'V')
            order by type, s.name, o.name
      end
Set @maxi = @@rowcount
set @i = 1

print '<table border="0" cellspacing="0" cellpadding="0" width="550px" align="center"><tr><td colspan="3" style="height:50;font-size:14pt;text-align:center;"><a name="index"></a><b>Index</b></td></tr></table>'
print '<table border="0" cellspacing="1" cellpadding="0" width="550px" align="center"><tr><th>Sr</th><th>Object</th><th>Type</th></tr>'
While(@i <= @maxi)
begin
   select @Output =  '<tr><td align="center">' + Cast((@i) as varchar) + '</td><td><a href="#' + Type + ':' + name + '">' + name + '</a></td><td>' + Type + '</td></tr>'
         from #Tables where id = @i
  
   print @Output
   set @i = @i + 1
end
print '</table><br />'

set @i = 1
While(@i <= @maxi)
begin
   --table header
   select @Output =  '<tr><th align="left"><a name="' + Type + ':' + name + '"></a><b>' + Type + ':' + name + '</b></th></tr>',  @description = [description]
         from #Tables where id = @i
  
   print '<br /><br /><br /><table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td align="right"><a href="#index">Index</a></td></tr>'
   print @Output
   print '</table><br />'
   print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Description</b></td></tr><tr><td>' + isnull(@description, '') + '</td></tr></table><br />'

   --table columns
   truncate table #Columns
   if @SqlVersion = '2000'
      begin
      insert into #Columns  (Name, Type, Nullable, [description])
      --FOR 2000
      Select c.name,
               type_name(xtype) + (
               case when (type_name(xtype) = 'varchar' or type_name(xtype) = 'nvarchar' or type_name(xtype) ='char' or type_name(xtype) ='nchar')
                  then '(' + cast(length as varchar) + ')'
                when type_name(xtype) = 'decimal' 
                     then '(' + cast(prec as varchar) + ',' + cast(scale as varchar)   + ')'
               else ''
               end           
               ),
               case when isnullable = 1 then 'Y' else 'N'  end,
               cast(p.value as varchar(8000))
            from syscolumns c
               inner join #Tables t on t.object_id = c.id
               left outer join sysproperties p on p.id = c.id and p.smallid = c.colid and p.name = 'MS_Description'
            where t.id = @i
            order by c.colorder
      end
   else if @SqlVersion = '2005'
      begin
      insert into #Columns  (Name, Type, Nullable, [description])
      --FOR 2005  
      Select c.name,
               type_name(user_type_id) + (
               case when (type_name(user_type_id) = 'varchar' or type_name(user_type_id) = 'nvarchar' or type_name(user_type_id) ='char' or type_name(user_type_id) ='nchar')
                  then '(' + cast(max_length as varchar) + ')'
                when type_name(user_type_id) = 'decimal' 
                     then '(' + cast([precision] as varchar) + ',' + cast(scale as varchar)   + ')'
               else ''
               end           
               ),
               case when is_nullable = 1 then 'Y' else 'N'  end,
               cast(p.value as varchar(4000))
      from sys.columns c
            inner join #Tables t on t.object_id = c.object_id
            left outer join sys.extended_properties p on p.major_id = c.object_id and p.minor_id  = c.column_id and p.name = 'MS_Description'
      where t.id = @i
      order by c.column_id
      end
   Set @maxj =   @@rowcount
   set @j = 1

   print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Table Columns</b></td></tr></table>'
   print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Datatype</th><th>Nullable</th><th>Description</th></tr>'
  
   While(@j <= @maxj)
   begin
      select @Output = '<tr><td width="20px" align="center">' + Cast((@j) as varchar) + '</td><td width="150px">' + isnull(name,'')  + '</td><td width="150px">' +  upper(isnull(Type,'')) + '</td><td width="50px" align="center">' + isnull(Nullable,'N') + '</td><td>' + isnull([description],'') + '</td></tr>'
         from #Columns  where id = @j
     
      print    @Output   
      Set @j = @j + 1;
   end

   print '</table><br />'

   --reference key
   truncate table #FK
   if @SqlVersion = '2000'
      begin
      insert into #FK  (Name, col, refObj, refCol)
   --      FOR 2000
      select object_name(constid), s.name,  object_name(rkeyid) ,  s1.name 
            from sysforeignkeys f
               inner join sysobjects o on o.id = f.constid
               inner join syscolumns s on s.id = f.fkeyid and s.colorder = f.fkey
               inner join syscolumns s1 on s1.id = f.rkeyid and s1.colorder = f.rkey
               inner join #Tables t on t.object_id = f.fkeyid
            where t.id = @i
            order by 1
      end  
   else if @SqlVersion = '2005'
      begin
      insert into #FK  (Name, col, refObj, refCol)
--      FOR 2005
      select f.name, COL_NAME (fc.parent_object_id, fc.parent_column_id) , object_name(fc.referenced_object_id) , COL_NAME (fc.referenced_object_id, fc.referenced_column_id)    
      from sys.foreign_keys f
         inner  join  sys.foreign_key_columns  fc  on f.object_id = fc.constraint_object_id  
         inner join #Tables t on t.object_id = f.parent_object_id
      where t.id = @i
      order by f.name
      end
  
   Set @maxj =   @@rowcount
   set @j = 1
   if (@maxj >0)
   begin

      print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Refrence Keys</b></td></tr></table>'
      print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Column</th><th>Reference To</th></tr>'

      While(@j <= @maxj)
      begin

         select @Output = '<tr><td width="20px" align="center">' + Cast((@j) as varchar) + '</td><td width="150px">' + isnull(name,'')  + '</td><td width="150px">' +  isnull(col,'') + '</td><td>[' + isnull(refObj,'N') + '].[' +  isnull(refCol,'N') + ']</td></tr>'
            from #FK  where id = @j

         print @Output
         Set @j = @j + 1;
      end

      print '</table><br />'
   end

   --Default Constraints
   truncate table #Constraint
   if @SqlVersion = '2000'
      begin
      insert into #Constraint  (Name, col, definition)
      select object_name(c.constid), col_name(c.id, c.colid), s.text
            from sysconstraints c
               inner join #Tables t on t.object_id = c.id
               left outer join syscomments s on s.id = c.constid
            where t.id = @i
            and
            convert(varchar,+ (c.status & 1)/1)
            + convert(varchar,(c.status & 2)/2)
            + convert(varchar,(c.status & 4)/4)
            + convert(varchar,(c.status & 8)/8)
            + convert(varchar,(c.status & 16)/16)
            + convert(varchar,(c.status & 32)/32)
            + convert(varchar,(c.status & 64)/64)
            + convert(varchar,(c.status & 128)/128) = '10101000'
      end
   else if @SqlVersion = '2005'
      begin
      insert into #Constraint  (Name, col, definition)
      select c.name,  col_name(parent_object_id, parent_column_id), c.definition
      from sys.default_constraints c
         inner join #Tables t on t.object_id = c.parent_object_id
      where t.id = @i
      order by c.name
      end
   Set @maxj =   @@rowcount
   set @j = 1
   if (@maxj >0)
   begin

      print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Default Constraints</b></td></tr></table>'
      print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Column</th><th>Value</th></tr>'

      While(@j <= @maxj)
      begin

         select @Output = '<tr><td width="20px" align="center">' + Cast((@j) as varchar) + '</td><td width="250px">' + isnull(name,'')  + '</td><td width="150px">' +  isnull(col,'') + '</td><td>' +  isnull(definition,'') + '</td></tr>'
            from #Constraint  where id = @j

         print @Output
         Set @j = @j + 1;
      end

   print '</table><br />'
   end


   --Check  Constraints
   truncate table #Constraint
   if @SqlVersion = '2000'
      begin
      insert into #Constraint  (Name, col, definition)
         select object_name(c.constid), col_name(c.id, c.colid), s.text
            from sysconstraints c
               inner join #Tables t on t.object_id = c.id
               left outer join syscomments s on s.id = c.constid
            where t.id = @i
            and ( convert(varchar,+ (c.status & 1)/1)
               + convert(varchar,(c.status & 2)/2)
               + convert(varchar,(c.status & 4)/4)
               + convert(varchar,(c.status & 8)/8)
               + convert(varchar,(c.status & 16)/16)
               + convert(varchar,(c.status & 32)/32)
               + convert(varchar,(c.status & 64)/64)
               + convert(varchar,(c.status & 128)/128) = '00101000'
            or convert(varchar,+ (c.status & 1)/1)
               + convert(varchar,(c.status & 2)/2)
               + convert(varchar,(c.status & 4)/4)
               + convert(varchar,(c.status & 8)/8)
               + convert(varchar,(c.status & 16)/16)
               + convert(varchar,(c.status & 32)/32)
               + convert(varchar,(c.status & 64)/64)
               + convert(varchar,(c.status & 128)/128) = '00100100')

      end
   else if @SqlVersion = '2005'
      begin
      insert into #Constraint  (Name, col, definition)
         select c.name,  col_name(parent_object_id, parent_column_id), definition
         from sys.check_constraints c
            inner join #Tables t on t.object_id = c.parent_object_id
         where t.id = @i
         order by c.name
      end
   Set @maxj =   @@rowcount
  
   set @j = 1
   if (@maxj >0)
   begin

      print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Check  Constraints</b></td></tr></table>'
      print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Column</th><th>Definition</th></tr>'

      While(@j <= @maxj)
      begin

         select @Output = '<tr><td width="20px" align="center">' + Cast((@j) as varchar) + '</td><td width="250px">' + isnull(name,'')  + '</td><td width="150px">' +  isnull(col,'') + '</td><td>' +  isnull(definition,'') + '</td></tr>'
            from #Constraint  where id = @j
         print @Output
         Set @j = @j + 1;
      end

      print '</table><br />'
   end


   --Triggers
   truncate table #Constraint
   if @SqlVersion = '2000'
      begin
      insert into #Constraint  (Name)
         select tr.name
         FROM sysobjects tr
            inner join #Tables t on t.object_id = tr.parent_obj
         where t.id = @i and tr.type = 'TR'
         order by tr.name
      end
   else if @SqlVersion = '2005'
      begin
      insert into #Constraint  (Name)
         SELECT tr.name
         FROM sys.triggers tr
            inner join #Tables t on t.object_id = tr.parent_id
         where t.id = @i
         order by tr.name
      end
   Set @maxj =   @@rowcount
  
   set @j = 1
   if (@maxj >0)
   begin

      print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Triggers</b></td></tr></table>'
      print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Description</th></tr>'

      While(@j <= @maxj)
      begin
         select @Output = '<tr><td width="20px" align="center">' + Cast((@j) as varchar) + '</td><td width="150px">' + isnull(name,'')  + '</td><td></td></tr>'
            from #Constraint  where id = @j
         print @Output
         Set @j = @j + 1;
      end

      print '</table><br />'
   end

   --Indexes
   truncate table #Indexes
   if @SqlVersion = '2000'
      begin
      insert into #Indexes  (Name, type, cols)
         select i.name, case when i.indid = 0 then 'Heap' when i.indid = 1 then 'Clustered' else 'Nonclustered' end , c.name
         from sysindexes i
            inner join sysindexkeys k  on k.indid = i.indid  and k.id = i.id
            inner join syscolumns c on c.id = k.id and c.colorder = k.colid
            inner join #Tables t on t.object_id = i.id
         where t.id = @i and i.name not like '_WA%'
         order by i.name, i.keycnt
      end
   else if @SqlVersion = '2005'
      begin
      insert into #Indexes  (Name, type, cols)
         select i.name, case when i.type = 0 then 'Heap' when i.type = 1 then 'Clustered' else 'Nonclustered' end,  col_name(i.object_id, c.column_id)
            from sys.indexes i
               inner join sys.index_columns c on i.index_id = c.index_id and c.object_id = i.object_id
               inner join #Tables t on t.object_id = i.object_id
            where t.id = @i
            order by i.name, c.column_id
      end

   Set @maxj =   @@rowcount
  
   set @j = 1
   set @sr = 1
   if (@maxj >0)
   begin

      print '<table border="0" cellspacing="0" cellpadding="0" width="750px"><tr><td><b>Indexes</b></td></tr></table>'
      print '<table border="0" cellspacing="1" cellpadding="0" width="750px"><tr><th>Sr.</th><th>Name</th><th>Type</th><th>Columns</th></tr>'
      set @Output = ''
      set @last = ''
      set @current = ''
      While(@j <= @maxj)
      begin
         select @current = isnull(name,'') from #Indexes  where id = @j
               
         if @last <> @current  and @last <> ''
            begin  
            print '<tr><td width="20px" align="center">' + Cast((@sr) as varchar) + '</td><td width="150px">' + @last + '</td><td width="150px">' + @typ + '</td><td>' + @Output  + '</td></tr>'
            set @Output  = ''
            set @sr = @sr + 1
            end
        
           
         select @Output = @Output + cols + '<br />' , @typ = type
               from #Indexes  where id = @j
        
         set @last = @current   
         Set @j = @j + 1;
      end
      if @Output <> ''
            begin  
            print '<tr><td width="20px" align="center">' + Cast((@sr) as varchar) + '</td><td width="150px">' + @last + '</td><td width="150px">' + @typ + '</td><td>' + @Output  + '</td></tr>'
            end

      print '</table><br />'
   end

    Set @i = @i + 1;
   --Print @Output
end


Print '</body>'
Print '</html>'

drop table #Tables
drop table #Columns
drop table #FK
drop table #Constraint
drop table #Indexes
set nocount off

'DEVELOPMENT > Database' 카테고리의 다른 글

동일 칼럼을 가지나, 이름을 달리하는 테이블 만들기  (0) 2009.07.14
ER-Win에서 DB Table 가져오기  (0) 2009.05.13
oracle 시작과 종료  (0) 2009.05.07
Toad 단축키  (0) 2009.04.18
[oracle] decode 함수  (1) 2009.01.16