C# »ñÈ¡ SQL·þÎñÆ÷Áбí
#region µÃµ½ËùÓб¾µØÍøÂçÖпÉʹÓõÄSQL·þÎñÆ÷Áбí
/// <summary>
/// µÃµ½ËùÓб¾µØÍøÂçÖпÉʹÓõÄSQL·þÎñÆ÷Áбí
/// </summary>
/// <param name="p_strServerList">·þÎñÆ÷Áбí</param>
/// <returns></returns>
public static bool GetServers(ref string [] p_strServerList)
{
try
{
SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers();
if(sqlServers.Count > 0)
{
p_strServerList = new string[sqlServers.Count];
for(int i=0;i<sqlServers.Count;i++)
{
string srv = sqlServers.Item(i + 1);
if(srv != null)
{
p_strServerList[i] = srv;
}
}
}
return true;
}
catch(Exception ex)
{
throw ex;
}
}
#endregion
#region µÃµ½Ö¸¶¨SQL·þÎñÆ÷ËùÓÐÊý¾Ý¿âµÄÁбí
/// <summary>
/// µÃµ½Ö¸¶¨SQL·þÎñÆ÷ËùÓÐÊý¾Ý¿âµÄÁбí
/// </summary>
/// <param name="p_strDataBas
Ïà¹ØÎĵµ£º
SQL ÖÐµÄ substring º¯ÊýÊÇÓÃÀ´×¥³öÒ»¸öÀ¸Î»×ÊÁÏÖÐµÄÆäÖÐÒ»²¿·Ö¡£Õâ¸öº¯ÊýµÄÃû³ÆÔÚ²»Í¬µÄ×ÊÁÏ¿âÖв»ÍêȫһÑù£º
MySQL: SUBSTR(), SUBSTRING()
Oracle: SUBSTR()
SQL Server: SUBSTRING()
×î³£Óõ½µÄ·½Ê½ÈçÏ (ÔÚÕâÀïÎÒÃÇÓÃSUBSTR()ΪÀý)£º
SUBSTR(str,pos): ÓÉ<str>ÖУ¬Ñ¡³öËùÓдӵÚ<pos>λÖÿªÊ¼µÄ× ......
ÊÓ¹Û±í (Views) ¿ÉÒÔ±»µ±×÷ÊÇÐéÄâ±í¸ñ¡£Ëü¸ú±í¸ñµÄ²»Í¬ÊÇ£¬±í¸ñÖÐÓÐʵ¼Ê´¢´æ×ÊÁÏ£¬¶øÊÓ¹Û±íÊǽ¨Á¢ÔÚ±í¸ñÖ®ÉϵÄÒ»¸ö¼Ü¹¹£¬Ëü±¾Éí²¢²»Êµ¼Ê´¢´æ×ÊÁÏ¡£
½¨Á¢Ò»¸öÊÓ¹Û±íµÄÓï·¨ÈçÏ£º
CREATE VIEW "VIEW_NAME" AS "SQL Óï¾ä"
"SQL Óï¾ä" ¿ÉÒÔÊÇÈκÎÒ»¸öÎÒÃÇÔÚÕâ¸ö½Ì²ÄÖÐÓÐÌáµ½µÄ SQL¡£
À´¿´Ò»¸öÀý×Ó¡£¼ÙÉèÎÒÃÇÓÐÒÔϵıí¸ñ£ ......
ÔÚ±í¸ñ±»½¨Á¢ÔÚ×ÊÁÏ¿âÖкó£¬ÎÒÃdz£³£»á·¢ÏÖ£¬Õâ¸ö±í¸ñµÄ½á¹¹ÐèÒªÓÐËù¸Ä±ä¡£³£¼ûµÄ¸Ä±äÈçÏ£º
¼ÓÒ»¸öÀ¸Î»
ɾȥһ¸öÀ¸Î»
¸Ä±äÀ¸Î»Ãû³Æ
¸Ä±äÀ¸Î»µÄ×ÊÁÏÖÖÀà
ÒÔÉÏÁгöµÄ¸Ä±ä²¢²»ÊÇËùÓпÉÄܵĸı䡣ALTER TABLE Ò²¿ÉÒÔ±»ÓÃÀ´×÷ÆäËûµÄ¸Ä±ä£¬ÀýÈç¸Ä±äÖ÷¼ü¶¨Òå¡£
ALTER TABLE µÄÓï·¨ÈçÏ£º
ALTER TABLE "table_name"
......