当前位置: 首页 > 图文教程 > 数据库 > MSSQL > ACCESS数据库向MySQL快速迁移小程序(二)

MSSQL
利用 Case 敘述做 SQL 的動態排列
SQL Server 2000 与 SQL Server 7.0 版兼容性问题
数据变换和转换注意事项(SQL)
浅谈优化SQLServer数据库服务器内存配置的策略
SQL2000管理SQL7服务器出现TIMEOUT问题的解决
Web环境下MS SQL Server中数据的磁带备份与恢复
SQL Server 7.0与以前的版本相比,安全模式中最重要的
如何用sql语句修改数据表中字段,实现identity(100,1)
sqlserver7.0中如何在死锁产生时自动将其杀死
Sql server使用内存限定在多少最为合适
使用MS SQL7的LINKED SERVER(一)
使用MS SQL7的LINKED SERVER(二)
使用MS SQL7的LINKED SERVER(三)
使用MS SQL7的LINKED SERVER(四)
SQL--JOIN之完全用法
总结 SQL Server 中死锁产生的原因及解决办法
数据库正规化和设计技巧
IDENTITY列的一个有用操作
聚合函数
当SQL Server数据库崩溃时如何恢复?

MSSQL 中的 ACCESS数据库向MySQL快速迁移小程序(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 71 ::
收藏到网摘: n/a

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下为 import.php 源程序
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<html>
<head>
<style type=text/css>
body,td,li,div,p,pre,a,b,h1,h2,h3,h4 {font-family:verdana;font-size:9pt;line-height : 18px;color:#a00000 }  
</style>
</head>
<body bgcolor=#f0f0f0 topmargin=0 leftmargin=0 text=#a00000>
<center>
<br>
<div style="font-size:24pt;font-family:times;font-weight:bold;color:#008000">ODBC --> MySQL Migrant</div>

<hr size=1 color=#900000>

<?  

    $dbconnection = @mysql_connect("yourmysqlserver", "mysqlaccount", "mysqlpassword")  
     
        or die ("can not connect to database server");
     
    @mysql_select_db("yourdatabase")   
              
             or die("<p style='font-size:9pt;font-family:verdana;color:#803333;font-weight:bold'>No Database,</p>") ;  


    $conn = odbc_connect("task", "", "");
     
    $fp = fopen ("fdlist.txt","r") ;
     
    $table1 = fgets($fp,200);

    $fd1 = fgets($fp,1024) ;

    $table2 = fgets($fp,200);

    $fd2 = fgets($fp,1024) ;
     
     
    $query1 =  "select " . $fd1 . " from " . $table1 ;  

    $query2 =  "select " . $fd2 . " from " . $table2 . " where 1=2 " ;
     
    $result = mysql_query ($query2) ;
     
    mysql_query ("delete from " .$table2 ) ;
     
    echo "sql=". $query1;
     
    $recordsid = odbc_exec($conn, $query1);
     
    $idcounts = odbc_num_fields( $recordsid ) ;
     
    $idcount2 = mysql_num_fields($result) ;
     
    if ( $idcounts != $idcount2 )  
        die (" The fields of two tables doesn't match ") ;

    echo "<table width=90% border=1 bordercolorlight=#000000 bordercolordark=#ffffff cellpadding=3 cellspacing=0>n" ;
     
     

    echo   "<tr align=center><td> n " ;
     
    for ( $i = 1 ; $i <= $idcounts ; $i ++)  
     
        echo  "n<td>" . odbc_field_name($recordsid,$i) ;
     
    $theno = 1 ;
     
    echo  "<tr>n" ;
     
     
     
    while (odbc_fetch_row($recordsid) )  {