2011年9月23日

ALTER TABLE

向表中增加一个 varchar 列:
ALTER TABLE distributors ADD COLUMN address varchar(30);

 

从表中删除一个字段:

ALTER TABLE distributors DROP COLUMN address RESTRICT;

 

在一个操作中修改两个现有字段的类型:  

ALTER TABLE distributors
    ALTER COLUMN address TYPE varchar(80),
    ALTER COLUMN name TYPE varchar(100);

 

使用一个 USING 子句,   把一个包含 UNIX 时间戳的 integer 字段转化成 timestamp with time zone

ALTER TABLE foo
    ALTER COLUMN foo_timestamp TYPE timestamp with time zone
    USING
        timestamp with time zone 'epoch' + foo_timestamp * interval '1 second';

 

对现存字段改名:

ALTER TABLE distributors RENAME COLUMN address TO city;

 

更改现存表的名字∶

ALTER TABLE distributors RENAME TO suppliers;

 

给一个字段增加一个非空约束:

ALTER TABLE distributors ALTER COLUMN street SET NOT NULL;

从一个字段里删除一个非空约束:

ALTER TABLE distributors ALTER COLUMN street DROP NOT NULL;

 

给一个表增加一个检查约束:

ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);

 

删除一个表和它的所有子表的监查约束:

ALTER TABLE distributors DROP CONSTRAINT zipchk;

 

向表中增加一个外键约束:

ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses(address) MATCH FULL;

 

给表增加一个(多字段)唯一约束:

ALTER TABLE distributors ADD CONSTRAINT dist_id_zipcode_key UNIQUE (dist_id, zipcode);

 

给一个表增加一个自动命名的主键约束,要注意的是一个表只能有一个主键:

ALTER TABLE distributors ADD PRIMARY KEY (dist_id);

 

把表移动到另外一个表空间:

ALTER TABLE distributors SET TABLESPACE fasttablespace;

 

把表移动到另外一个模式:

ALTER TABLE myschema.distributors SET SCHEMA yourschema;

posted @ 2011-09-23 13:50 newr2006 阅读(240) 评论(0) 编辑

2011年9月19日

unable to add host to SCVMM 2008R2

摘要: SCVMM issure阅读全文

posted @ 2011-09-19 19:11 newr2006 阅读(22) 评论(0) 编辑

2011年8月25日

Cannot generate SSPI context

摘要: Cannot generate SSPI context阅读全文

posted @ 2011-08-25 14:25 newr2006 阅读(38) 评论(0) 编辑

2009年12月7日

ASP.NET代码对页面输出进行清理

好的代码,自然要保存:

代码
private static readonly Regex REGEX_LINE_BREAKS = new Regex(@"\n\s*", RegexOptions.Compiled);
private static readonly Regex REGEX_LINE_SPACE = new Regex(@"\n\s*\r", RegexOptions.Compiled);
private static readonly Regex REGEX_SPACE = new Regex(@"( )+", RegexOptions.Compiled);

protected override void Render(HtmlTextWriter writer)
{
    
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
    {
        
base.Render(htmlwriter);
        
string html = htmlwriter.InnerWriter.ToString();
        html 
= REGEX_LINE_BREAKS.Replace(html, string.Empty);
        html 
= REGEX_LINE_SPACE.Replace(html, string.Empty);
        html 
= REGEX_SPACE.Replace(html, " ");
        writer.Write(html.Trim());
    }
}

 

 

posted @ 2009-12-07 11:19 newr2006 阅读(34) 评论(0) 编辑

2009年5月4日

提前两天发邮件

提前两天发邮件,

public static void SendMail(object sender, ElapsedEventArgs e)
        {          
            foreach (KeyValuePair<string, System.Timers.Timer> keyValuePair in Globals.TimerLists)
            {
                if (keyValuePair.Value == sender)
                {
                    string machineId = keyValuePair.Key;
                    using (Database accessor = new Database())
                    {
                        CheckOutInfo info = accessor.SelectCheckoutRecord(machineId);
                        if(info == null)
                        {
                            return;
                        }
                        //info.DueDate is expriation day
                        TimeSpan diff = DateTime.Now.Subtract(info.DueDate) + new TimeSpan(2, 0, 0, 0, 0);
                        diff = diff.Add(new TimeSpan(1, 0, 0)); // Add 1 hour to ignore the short time elapsed during processing.

                        // reSet the interval to let timer trigger next day.
                        if (diff.TotalDays < 0)
                        {
                            Debug.WriteLine("diff.Seconds< 0");
                            System.Timers.Timer reminderTimer = (System.Timers.Timer)sender;
                            reminderTimer.Interval = GetNextTriggerInterval(info.DueDate);
                            Debug.WriteLine(reminderTimer.Interval.ToString());
                            reminderTimer.AutoReset = false;
                            reminderTimer.Enabled = true;
                            break;
                        }
                        //Email reminder should be sent from 2 days before expiration;
                        else if (diff.TotalDays <= 2.0 && diff.TotalDays>=0.0)
                        {
                            VM vm = ShareFactory.GetVMByID(new Guid(machineId));
                            if (vm != null)
                            {
                                System.Timers.Timer reminderTimer = (System.Timers.Timer)sender;
                                reminderTimer.Interval = GetNextTriggerInterval(info.DueDate);
                                Debug.WriteLine(reminderTimer.Interval.ToString());
                                reminderTimer.AutoReset = false;
                                reminderTimer.Enabled = true;

                                string  Language = accessor.GetMachineLanguage(machineId);
                                ReservePolicy reservePolicy = ConfigurationFactory.GetReservePolicy(info.ReserveType);
                                if (info.ExtendTimes < reservePolicy.ExtendTimes)
                                {
                                    Debug.WriteLine("SendExpireEmail");                                 
                                }
                                else
                                {
                                    Debug.WriteLine("SendCheckinEmail");
                                 
                                }
                            }
                            else
                            {
                                // Machine does not exist. Just delete the records.
                               Debug.WriteLine("Machine does not exist. Just delete the records.");                             
                                Globals.TimerLists.Remove(machineId);
                            }

                        }
                        else
                        {
                             Debug.WriteLine("CheckIn");                           
                        }
                    }

                    break;
                }
            }
        }

posted @ 2009-05-04 14:12 newr2006 阅读(102) 评论(0) 编辑

2009年1月20日

线程 Thread 传参数

摘要: private static void IsVMStateChanged(object status) { object[] parms = (object[])status; string machineId = (string)parms[0];VM vm = ShareFactory.GetVMByID(new Guid(machineId)); if (vm.StatusString.E...阅读全文

posted @ 2009-01-20 19:39 newr2006 阅读(531) 评论(0) 编辑

2008年11月21日

好的博客

摘要: 先站个地放以后慢慢的加....1.国内好的技术博客(1):总结一些常用功能源码(2): 网站性能的提升:http://www.cnblogs.com/WizardWu/archive/2009/01/03/1367527.html整站性能http://www.cnblogs.com/WizardWu/archive/2008/10/27/1320055.html数据库性能http://kxm371...阅读全文

posted @ 2008-11-21 14:01 newr2006 阅读(26) 评论(0) 编辑

2008年10月14日

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. 解决办法

摘要: 今天下载了最新的CS2008 试了试,安装完数据库后出现这个问题:Specific Error Message:Unable to open connection to data provider.Cannot open database "CommunityServer" requested by the login. The login failed. Login failed for use...阅读全文

posted @ 2008-10-14 14:01 newr2006 阅读(370) 评论(0) 编辑

2008年10月6日

Hashtable(HashSet),ListDictionary,HybridDictionary 和 NameValueCollection

摘要: 相同点:1.大家都是存储键-值对的;(key-value)2.以后知道了再补充;不同点:1.Hashtable,ListDictionary,HashSet性能上 小数据量: ListDictionary优于Hashtable(10条以下)大数据量: Hashtable优于ListDictionary要知道Hashtable并不是线性存储结构,数据加入哈希表的时候的顺序和迭代输出的顺序不一致.但是...阅读全文

posted @ 2008-10-06 15:58 newr2006 阅读(392) 评论(0) 编辑

2008年9月27日

Pocket pc 与 Smartphone 开发的区别

摘要: Pocket PC和Smartphone都是微软Windows Mobile下的子品牌产品。 两者的内核都一样,都是基于WinCE 至于Pocket PC和Smartphone的区别,从直观上来看: 1.PPC具有触摸屏,SP没有 2.PPC的常规分辨率是320X240和640X480,SP是176X220和240X320 3.很多常规控件的表现形...阅读全文

posted @ 2008-09-27 12:38 newr2006 阅读(481) 评论(1) 编辑

导航

<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

公告

昵称:newr2006
园龄:4年7个月
粉丝:0
关注:0

搜索

 
 

常用链接

我的标签

随笔档案

最新评论

阅读排行榜

评论排行榜

推荐排行榜