asp建立表,複製表 欄位類型附錄_應用技巧

來源:互聯網
上載者:User
在已有資料庫中建立表 
<% set conn=server.CreateObject("adodb.connection") 
sql="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("BOOK.mdb") 
conn.open sql 
Conn.Execute("create table bbb(id AUTOINCREMENT(1,1),p_id text(100),ee money,ff datetime default date(),gg guid,hh single default 50,ii double,jj smallint,kk long,ll image,mm memo,oo yesno not null,pp TINYINT,qq numeric(18,4),aa binary,bb bit,cc smallint,)") 
%> 

'將a表另外複製一個b表(只複製結構,不含資料) 
  <% 
  Set rs= Server.CreateObject("ADODB.Recordset") 
  sql="select * into b from a where 1=0" 
  rs.open sql,conn,1,1 
  rs.update 
  rs.close 
  set rs=nothing 
  %> 
  ◆'將a表另外複製一個b表(包括制結構和資料) 
  <% 
  Set rs= Server.CreateObject("ADODB.Recordset") 
  sql="select * into b from a 
  rs.open sql,conn,1,1 
  rs.update 
  rs.close 
  set rs=nothing 
  %> 

12、建立資料庫並建立表 
<%   
'首先建立一個資料庫檔案   
set  conn=server.createobject("adox.catalog")   
conn.create  "provider=microsoft.jet.oledb.4.0;"&"data source="&server.mappath("lifeda1.mdb")   
%>   
<%   
'向該資料庫中建立相應表格   
set  rs=server.createobject("adox.table")   
'該表格名稱   
rs.name="aaaa"   
'該表格欄位(欄位類型見相關附錄)   
rs.columns.append  "id" ,3 
rs.columns.append  "liuyan",203     
rs.columns.append  "dt",7   
conn.tables.append  rs   
set  rs=nothing   
%>   
至此,表格建立完畢。希望能對您有協助。   
欄位類型附錄   
203  備忘   
7  日期/時間   
128  二進位   
11  布爾   
6  貨幣   
133  日期   
134  時間   
135  日期時間   
5  雙精確度   
4  單精確度  
3  數字  
204  二進位   
202  字串

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.