¸½¼Ósql server 20005Êý¾Ý¿â
·½·¨Ò»£º
1.Èç¹û¸½¼ÓÊý¾Ý¿âʱ£¬Ã»ÓÐÖ¸¶¨Âß¼Ãû£¬ÔòÔÚSQL2005ÉÏÏÔʾΪ“ȫ·¾¶£¬ÇÒΪ´óд”¡£±ÈÈ磬Êý¾Ý¿âÎļþD:MyTest.mdfºÍD:MyTest.ldf£¬¸½¼Óµ½SQL·þÎñÆ÷ÉÏʱ£¬Èç¹ûûÓÐÖ¸¶¨Âß¼Ãû£¬ÔòÔÚSQL2005ÉÏÏÔʾΪ“D:MYTEST.MDF”¡£´Ëʱ£¬C#µÄÁ¬½Ó×Ö·û´®Îª“DataSource=dsName;AttatchDBFilename=”D:\MyTest.mdf”;User ID=id;Password=pw”£»
2.Èç¹û¸½¼ÓÊý¾Ý¿âʱ£¬Ö¸¶¨ÁËÂß¼Ãû£¬ÔòÔÚSQL2005ÉÏÏÔʾΪ“Âß¼Ãû”£¬´Ëʱ£¬C#µÄÁ¬½Ó×Ö·û´®Îª“DataSource=dsName;AttatchDBFilename=”D:\MyTest.mdf”;Initial Catalog=aa_LogicName;User ID=id;Password=pw”£»
3.±»¸½¼ÓµÄÊý¾Ý¿âÃû³Æ²»¿ÉËæÒâ¸ü¸Ä£»·ñÔòÈÝÒ׳öÏÖ´íÎó¡£
·½·¨¶þ£º
string DbPath=System.Environment.CurrentDirectory +@"\Demo_Data.MDF";
string LogPath=System.Environment.CurrentDirectory +@"\Demo_Log.LDF";
string StrSql="exec sp_attach_db @dbname='supmark',@filename1='"+DbPath+"',@filename2='"+LogPath+"'";
string strcon="Server=(local);Integrated Security=SSPI;Database=master";
SqlConnection cn=new SqlConnection(strcon);
SqlCommand cmd =new SqlCommand (StrSql,cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
·½·¨ÈýÏêϸ´úÂ룺
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using System.ServiceProcess;
namespace AdminZJC.DataBaseControl
{
/// <summary>
/// Êý¾Ý¿â²Ù×÷¿ØÖÆÀà
/// </summary>
public class DataBaseControl
{
/// <summary>
/// Êý¾Ý¿âÁ¬½Ó×Ö·û´®
/// </summary>
public string ConnectionString;
/// <summary>
/// SQL²Ù×÷Óï¾ä/´æ´¢¹ý³Ì
/// </summary>
public string StrSQL;
/// <summary>
/// ʵÀý»¯Ò»¸öÊý¾Ý¿âÁ¬½Ó¶ÔÏó
/// </summary>
private SqlConnection Conn;
/// <summary>
/// ʵÀý»¯Ò»¸öеÄÊý¾Ý¿â²Ù×÷¶ÔÏóComm
/// </summary>
private SqlCommand Comm;
/// <summary>
/// Òª²Ù×÷µÄÊý¾Ý¿âÃû³Æ
/// </summary>
public string DataBaseName;
/// <summary>
/// Êý¾Ý¿âÎļþÍêÕûµØÖ
Ïà¹ØÎĵµ£º
SQLÓïÑÔÓÉÃüÁî¡¢×Ӿ䡢ÔËËãºÍ¼¯ºÏº¯ÊýµÈ¹¹³É¡£ÔÚSQLÖУ¬Êý¾Ý¶¨ÒåÓïÑÔDDL£¨ÓÃÀ´½¨Á¢¼°¶¨ÒåÊý¾Ý±í¡¢×Ö¶ÎÒÔ¼°Ë÷ÒýµÈÊý¾Ý¿â½á¹¹£©°üº¬µÄÃüÁîÓÐCREATE¡¢DROP¡¢ALTER£»Êý¾Ý²Ù×ÝÓïÑÔDML£¨ÓÃÀ´ÌṩÊý¾ÝµÄ²éѯ¡¢ÅÅÐòÒÔ¼°É¸Ñ¡Êý¾ÝµÈ¹¦ÄÜ£©°üº¬µÄÃüÁîÓÐSELECT¡¢INSERT¡¢UPDATE¡¢DELETE¡£
Ò»¡¢SQLÓï¾ä
£¨1£©Select ²éѯÓï¾ä
Óï ......
Èý¡¢Ç¶Ì×±íµÄʹÓ÷½·¨
1¡¢½«Ç¶Ì×±í¶¨ÒåΪPL/SQLµÄ³ÌÐò¹¹Ôì¿é
TYPE type_name IS TABLE OF element_type[NOT NULL];
ÈçÏÂÀýËùʾ£º
DECLARE
-- Define a nested table of variable length strings.
TYPE card_table IS TABLE OF VARCHAR2(5 CHAR);
-- Declare and initialize a n ......
window.onerror = function() { return true; };
body {margin:0;overflow:auto;font:normal 14px Verdana;background:#fff;padding:2px 4px 0;}body, p, font, div, li { line-height: 150%;}body, td, th {color:#000000;}.i {width:100%;*width:auto;table-layout:fixed;}pre {white-space: pre-wrap;white-spa ......
ORACLE SQLÓï¾äÓÅ»¯×ܽá
1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, Ä ......