一年之計在於春!新年快樂!
Mnemostylist
There are no limits. There are plateaus, but you must not stay there, you must go beyond them. - Bruce Lee
Mnemorable
- I love those who can smile in trouble, who can gather strength from distress, and grow brave by reflection. 'Tis the business of little minds to shrink, but they whose heart is firm, and whose conscience approves their conduct, will pursue their principles unto death. - [Leonardo da Vinci]
- Standing on the Shoulder of Giants - One who develops future intellectual pursuits by understanding the research and works created by notable thinkers of the past.
- A hundred times every day I remind myself that my inner and outer life are based on the labors of other men, living and dead, and that I must exert myself in order to give in the same measure as I have received and am still receiving... - [Albert Einstein]
Tuesday, May 19, 2009
Myers-Briggs Type Indicator, MBTI
[Link] Wiki
迈尔斯-布里格斯性格分类法(Myers-Briggs Type Indicator,MBTI)是性格分类的一种,其基本理论是根据瑞士心理分析家荣格于1921年所出版的书籍心理类型(Psychological Types )。
最先的开发者是美国的心理学家Katherine Cook Briggs及其女儿Isabel Briggs Myers,经过长期观察和研究而完成。
虽然备受学术派的心理学者所批评,但经过五十多年的发展,MBTI现已成为全球著名的性格测试之一。
当中包括教育界、顾员招聘及培训、领袖训练及个人发展等领域均有广泛的应用。
学术派的心理学家常批评MBTI理论缺乏可靠的数据支持,并指出这是巴纳姆效应的例子。
测试元素
这四个问题是:
性格动力学
「外向」与「内向」
发泄及获得心灵能量的方向。
外向型(E, Extraverts)偏向专注于外在的人和事,倾向将能量往外释放。
内向型(I, Introverts)则专注于自己的思想、想法及印象,倾向将能量流往内。
「直觉」与「感觉」
是人们认识世界的非理性方法,即外界知觉,所说的是人们如何处理接收到的资料。
感觉型(S, Sensing)喜欢着眼于当前事物,惯于先使用五官来感受世界。
直觉型(N, Intuition)则着眼未来,着重可能性及预感,从潜意识及事物间的关联来理解世界。
「情感」与「思考」
情感及思考是下决定时内心斗争所侧重的方向,并配合以上的能量走向。
情感型(F, Feeling)偏好使用价值观及自我中心的主观评价来作决定。可以说成思考型使用头脑来作决定,而情感型则用内心来作决定。
思考型(T, Thinking)则偏好用「是-非」及「如果...就」的逻辑来作分析结果及影响,或者作决定。
例子:外向的思考型(Te)及情感型(Se)倾向倚赖外在事物及为人接受的规则来作决定;反之,内向的思考型(Ti)及情感型(Fi)则倾向于主观,倚赖自己的想法来构建逻辑组织及评价。
「判断」与「理解」
处世态度及生活模式
判断型(J, Judging)倾向于井然有序及有组织的生活,而且喜欢安顿一切事物。
理解型(P, Perceiving)则倾向于自然发生及弹性的生活,对任何意见都抱开放态度。
要注意的是,判断(Judging)并不等同决断(Judgmental,包含主观及冲动的意思),而理解(Perceiving)亦不解作感知(Perceptive,指对感觉作出反应的程度)。
测验结果分为十六种性格:
01) ESTJ大男人型
02) ESTP挑战型
03) ESFJ主人型
04) ESFP表演型
05) ENTJ将军型
06) ENTP发明家
07) ENFJ教育家
08) ENFP记者型
09) ISTJ公务型
10) ISTP冒险家
11) ISFJ照顾型
12) ISFP艺术家
13) INTJ专家型
14) INTP学者型
15) INFJ作家型
16) INFP哲学家
实际上这16种类型又归于四个大类之中,在此我们将四个大类型筛选,并总结如下:
[参考来源]
SJ型:忠诚的监护人
具有SJ偏爱的人他们的共性是有很强的责任心与事业心,他们忠诚、按时完成任务,推崇安全、礼议、规则和服从,他们被一种服务于社会需要的强烈动机所驱使。他们坚定、尊重权威、等级制度,持保守的价值观。他们充当着保护者、管理员、稳压器、监护人的角色。大约有50%左右SJ偏爱的人为政府部门及军事部门的职务所吸引,并且显现出卓越成就。其中在美国执政过的41位总统中有20位是SJ偏爱的人。
例如:乔治.布什George Bush,女王维多利亚Queen Victoria,女王伊丽莎白.伊伊Queen Elizabeth,乔治.华盛顿George Washington
SP型:天才的艺术家
有SP偏好的人有冒险精神,反应灵敏,在任何要求技巧性强的领域中游刃有余,他们常常被认为是喜欢活在危险边缘寻找刺激的人。他们为行动,冲动和享受现在而活着:约有60%左右sp偏好的人喜欢艺术、娱乐、体育和文学,他们被称赞为天才的艺术家。歌星麦当娜、兰球魔术师约翰逊、音乐大师莫扎特等都是具有SP性格特点的例子。
例如:迈克尔.乔丹Michael Jordan,伊丽莎白.泰勒Elizabet Taylor,玛丽莲.梦露Marilyn Monroe,帕布洛.毕加索Pablo Picasso
NT型:科学家、思想家的摇篮
NT偏爱的人有着天生好奇心,喜欢梦想,有独创性、创造力、洞察力、有兴趣获得新知识,有极强的分析问题、解决问题的能力。他们是独立的、理性的、有能力的人。人们称NT是思想家、科学家的摇篮,大多数NT类型的人喜欢物理、研究、管理、电脑、法律、金融、工程等理论性和技术性强的工作。
例如:比尔·盖茨Bill Gates,乔治·索罗斯George Soros,伯特·爱因斯坦Albert Einstein,玛格丽特·萨切尔Margaret Thatcher
NF型:理想主义者、精神领袖
NF偏爱的人在精神上有极强的哲理性,他们善于言辩、充满活力、有感染力、能影响他人的价值观并鼓舞其激情。他们帮助别人成长和进步,具有煽动性,被称为传播者和催化剂。约有一半的人在教育界、文学界、宗教界、咨询界以及心理学、文学、美术和音乐等行业显示着他们的非凡成就。
例如:夫拉迪默.列宁VLadimir Lenin,奥普拉.温弗尼Oprah Winfrey,夏洛特姐妹Emily Bronte andDickenson,莫汉迪斯.甘地Mohandas Gandhi
There are four temperaments: SJ, SP, NT, and NF.
[Link]
SJ -
Sensing judgers, or traditionalists, are practical people that keep the home fires burning and businesses working. They're always aware of who owns what and which social positions are held by whom. Their quest is to run everything, and they are often good at doing so.
SP -
Sensing perceivers, or experiencers, are adventurous, fun-loving, observant, physically skillful, impatient, easily bored , and good with tools and art. They want to be happy and make others happy too.
NT -
Intuitive thinkers, or conceptualizers, are analytical, impersonal, intellectual, rather unworldly, absent-minded, and are more likely to forget appointments. They continually seek to acquire new skills and pride themselves on their skills, logic, and efficiency.
NF -
Intuitive feelers, or idealists, understand people and tend to be aware of people's feelings. They can be warm, sympathetic friends, but find offense in the smallest careless remark. They tend to be very skillful negotiators and good with words.
做个记录,更了解自己,也许人的性格真的是会变的,让以后有个借鉴。
这一次的测试网址[Link],以下是测试结果,和上一次的测试结果一样是[INTJ]:
分析:您的性格类型是「INTJ」(专家型)
在实现自己的想法和达成自己的目标时有创新的想法和非凡的动力。能很快洞察到外界事物间的规律并形成长期的远景计划。一旦决定做一件事就会开始规划并直到完成为止。多疑、独立,对于自己和他人能力和表现的要求都非常高。 INTJ型的人是完美主义者。他们强烈地要求个人自由和能力,同时在他们独创的思想中,不可动摇的信仰促使他们达到目标。 INTJ型的人思维严谨、有逻辑性、足智多谋,他们能够看到新计划实行后的结果。他们对自己和别人都很苛求,往往几乎同样强硬地逼迫别人和自己。他们并不十分受冷漠与批评的干扰,作为所有性格类型中最独立的,INTJ型的人更喜欢以自己的方式行事。面对相反意见,他们通常持怀疑态度,十分坚定和坚决。权威本身不能强制地们,只有他们认为这些规则对自己的更重要的目标有用时,才会去遵守。 INTJ型的人是天生的谋略家,具有独特的思想、伟大的远见和梦想。他们天生精于理论,对于复杂而综合的概念运转灵活。他们是优秀的战略思想家,通常能清楚地看到任何局势的利处和缺陷。对于感兴趣的问题,他们是出色的、具有远见和见解的组织者。如果是他们自己形成的看法和计划,他们会投入不可思议的注意力、能量和积极性。领先到达或超过自己的高标准的决心和坚忍不拔,使他们获得许多成就。
您适合的领域有:科学研究、科技应用、技术咨询、管理咨询、金融、投资领域、创造性行业
您适合的职业有:
首席财政执行官
知识产权律师
设计工程师
精神分析师
心脏病专家
媒体策划
网络管理员
建筑师
管理顾问
经济学者
国际银行业务职员
金融规划师
综合网络专业人员
各类科学家
研究所研究人员
系统分析员
计算机程序师
研究开发部经理
各类技术顾问
技术专家
投资专家
法律顾问
医学专家
经济学家
投资银行研究员
证券投资和金融分析员
投资银行家
财务计划人员
企业并购专家
各类发明家
建筑师
社论作家
艺术家
迈尔斯-布里格斯性格分类法(Myers-Briggs Type Indicator,MBTI)是性格分类的一种,其基本理论是根据瑞士心理分析家荣格于1921年所出版的书籍心理类型(Psychological Types )。
最先的开发者是美国的心理学家Katherine Cook Briggs及其女儿Isabel Briggs Myers,经过长期观察和研究而完成。
虽然备受学术派的心理学者所批评,但经过五十多年的发展,MBTI现已成为全球著名的性格测试之一。
当中包括教育界、顾员招聘及培训、领袖训练及个人发展等领域均有广泛的应用。
学术派的心理学家常批评MBTI理论缺乏可靠的数据支持,并指出这是巴纳姆效应的例子。
测试元素
这四个问题是:
- 心理能力的走向:你是「外向」(Extrovert)(E)还是「内向」(Introvert)(I)?
- 认识外在世界的方法:你是「感觉」(Sensing)(S)还是「直觉」(Intuition)(N)?
- 倚赖什么方式做决定:你是「理性」(Thinking)(T)还是「情感」(Feeling)(F)?
- 生活方式和处事态度:你是「判断」(Judging)(J)还是「理解」(Perceiving)(P)?
性格动力学
「外向」与「内向」
发泄及获得心灵能量的方向。
外向型(E, Extraverts)偏向专注于外在的人和事,倾向将能量往外释放。
内向型(I, Introverts)则专注于自己的思想、想法及印象,倾向将能量流往内。
「直觉」与「感觉」
是人们认识世界的非理性方法,即外界知觉,所说的是人们如何处理接收到的资料。
感觉型(S, Sensing)喜欢着眼于当前事物,惯于先使用五官来感受世界。
直觉型(N, Intuition)则着眼未来,着重可能性及预感,从潜意识及事物间的关联来理解世界。
「情感」与「思考」
情感及思考是下决定时内心斗争所侧重的方向,并配合以上的能量走向。
情感型(F, Feeling)偏好使用价值观及自我中心的主观评价来作决定。可以说成思考型使用头脑来作决定,而情感型则用内心来作决定。
思考型(T, Thinking)则偏好用「是-非」及「如果...就」的逻辑来作分析结果及影响,或者作决定。
例子:外向的思考型(Te)及情感型(Se)倾向倚赖外在事物及为人接受的规则来作决定;反之,内向的思考型(Ti)及情感型(Fi)则倾向于主观,倚赖自己的想法来构建逻辑组织及评价。
「判断」与「理解」
处世态度及生活模式
判断型(J, Judging)倾向于井然有序及有组织的生活,而且喜欢安顿一切事物。
理解型(P, Perceiving)则倾向于自然发生及弹性的生活,对任何意见都抱开放态度。
要注意的是,判断(Judging)并不等同决断(Judgmental,包含主观及冲动的意思),而理解(Perceiving)亦不解作感知(Perceptive,指对感觉作出反应的程度)。
测验结果分为十六种性格:
01) ESTJ大男人型
02) ESTP挑战型
03) ESFJ主人型
04) ESFP表演型
05) ENTJ将军型
06) ENTP发明家
07) ENFJ教育家
08) ENFP记者型
09) ISTJ公务型
10) ISTP冒险家
11) ISFJ照顾型
12) ISFP艺术家
13) INTJ专家型
14) INTP学者型
15) INFJ作家型
16) INFP哲学家
实际上这16种类型又归于四个大类之中,在此我们将四个大类型筛选,并总结如下:
[参考来源]
SJ型:忠诚的监护人
具有SJ偏爱的人他们的共性是有很强的责任心与事业心,他们忠诚、按时完成任务,推崇安全、礼议、规则和服从,他们被一种服务于社会需要的强烈动机所驱使。他们坚定、尊重权威、等级制度,持保守的价值观。他们充当着保护者、管理员、稳压器、监护人的角色。大约有50%左右SJ偏爱的人为政府部门及军事部门的职务所吸引,并且显现出卓越成就。其中在美国执政过的41位总统中有20位是SJ偏爱的人。
例如:乔治.布什George Bush,女王维多利亚Queen Victoria,女王伊丽莎白.伊伊Queen Elizabeth,乔治.华盛顿George Washington
SP型:天才的艺术家
有SP偏好的人有冒险精神,反应灵敏,在任何要求技巧性强的领域中游刃有余,他们常常被认为是喜欢活在危险边缘寻找刺激的人。他们为行动,冲动和享受现在而活着:约有60%左右sp偏好的人喜欢艺术、娱乐、体育和文学,他们被称赞为天才的艺术家。歌星麦当娜、兰球魔术师约翰逊、音乐大师莫扎特等都是具有SP性格特点的例子。
例如:迈克尔.乔丹Michael Jordan,伊丽莎白.泰勒Elizabet Taylor,玛丽莲.梦露Marilyn Monroe,帕布洛.毕加索Pablo Picasso
NT型:科学家、思想家的摇篮
NT偏爱的人有着天生好奇心,喜欢梦想,有独创性、创造力、洞察力、有兴趣获得新知识,有极强的分析问题、解决问题的能力。他们是独立的、理性的、有能力的人。人们称NT是思想家、科学家的摇篮,大多数NT类型的人喜欢物理、研究、管理、电脑、法律、金融、工程等理论性和技术性强的工作。
例如:比尔·盖茨Bill Gates,乔治·索罗斯George Soros,伯特·爱因斯坦Albert Einstein,玛格丽特·萨切尔Margaret Thatcher
NF型:理想主义者、精神领袖
NF偏爱的人在精神上有极强的哲理性,他们善于言辩、充满活力、有感染力、能影响他人的价值观并鼓舞其激情。他们帮助别人成长和进步,具有煽动性,被称为传播者和催化剂。约有一半的人在教育界、文学界、宗教界、咨询界以及心理学、文学、美术和音乐等行业显示着他们的非凡成就。
例如:夫拉迪默.列宁VLadimir Lenin,奥普拉.温弗尼Oprah Winfrey,夏洛特姐妹Emily Bronte andDickenson,莫汉迪斯.甘地Mohandas Gandhi
There are four temperaments: SJ, SP, NT, and NF.
[Link]
SJ -
Sensing judgers, or traditionalists, are practical people that keep the home fires burning and businesses working. They're always aware of who owns what and which social positions are held by whom. Their quest is to run everything, and they are often good at doing so.
SP -
Sensing perceivers, or experiencers, are adventurous, fun-loving, observant, physically skillful, impatient, easily bored , and good with tools and art. They want to be happy and make others happy too.
NT -
Intuitive thinkers, or conceptualizers, are analytical, impersonal, intellectual, rather unworldly, absent-minded, and are more likely to forget appointments. They continually seek to acquire new skills and pride themselves on their skills, logic, and efficiency.
NF -
Intuitive feelers, or idealists, understand people and tend to be aware of people's feelings. They can be warm, sympathetic friends, but find offense in the smallest careless remark. They tend to be very skillful negotiators and good with words.
做个记录,更了解自己,也许人的性格真的是会变的,让以后有个借鉴。
这一次的测试网址[Link],以下是测试结果,和上一次的测试结果一样是[INTJ]:
分析:您的性格类型是「INTJ」(专家型)
在实现自己的想法和达成自己的目标时有创新的想法和非凡的动力。能很快洞察到外界事物间的规律并形成长期的远景计划。一旦决定做一件事就会开始规划并直到完成为止。多疑、独立,对于自己和他人能力和表现的要求都非常高。 INTJ型的人是完美主义者。他们强烈地要求个人自由和能力,同时在他们独创的思想中,不可动摇的信仰促使他们达到目标。 INTJ型的人思维严谨、有逻辑性、足智多谋,他们能够看到新计划实行后的结果。他们对自己和别人都很苛求,往往几乎同样强硬地逼迫别人和自己。他们并不十分受冷漠与批评的干扰,作为所有性格类型中最独立的,INTJ型的人更喜欢以自己的方式行事。面对相反意见,他们通常持怀疑态度,十分坚定和坚决。权威本身不能强制地们,只有他们认为这些规则对自己的更重要的目标有用时,才会去遵守。 INTJ型的人是天生的谋略家,具有独特的思想、伟大的远见和梦想。他们天生精于理论,对于复杂而综合的概念运转灵活。他们是优秀的战略思想家,通常能清楚地看到任何局势的利处和缺陷。对于感兴趣的问题,他们是出色的、具有远见和见解的组织者。如果是他们自己形成的看法和计划,他们会投入不可思议的注意力、能量和积极性。领先到达或超过自己的高标准的决心和坚忍不拔,使他们获得许多成就。
您适合的领域有:科学研究、科技应用、技术咨询、管理咨询、金融、投资领域、创造性行业
您适合的职业有:
首席财政执行官
知识产权律师
设计工程师
精神分析师
心脏病专家
媒体策划
网络管理员
建筑师
管理顾问
经济学者
国际银行业务职员
金融规划师
综合网络专业人员
各类科学家
研究所研究人员
系统分析员
计算机程序师
研究开发部经理
各类技术顾问
技术专家
投资专家
法律顾问
医学专家
经济学家
投资银行研究员
证券投资和金融分析员
投资银行家
财务计划人员
企业并购专家
各类发明家
建筑师
社论作家
艺术家
Thursday, April 30, 2009
Choosing the Right Backup in SQL Server
[Source]
The article describes four different methods of backin up a SQL Server database; when to use them and why.
by Joe Lax, SQL Server Pro
When I started using SQL Server in version 4.2, backups were relatively simple. There were only two possibilities: a full backup or a transaction log backup. Starting with SQL Server 7, additional choices have proliferated. You now have four ways to back up your database.
If you are responsible for maintaining SQL Server databases, you need to be familiar with these various options and know when to apply each backup type. In this 10-Minute Solution, I show you the commands to execute each different kind of backup and discuss how to choose among the various options you have.
[THE PROBLEM]
How many different ways can you back up your SQL Server database?
[THE SOLUTION]
SQL Server provides four different methods for backing up your database:
Components of a SQL Server Database
Before exploring each of the various options in backing up a SQL Server database, let's review how information is stored in one.
A SQL Server database stores data in one or more database files. While many databases only use a single file to store data, there are good reasons sometimes to split your data among several files. As an example, if you need the extra performance, you can store tables that are frequently used in their own separate files. By placing those files on separate disks, you avoid contention for disk access. Or your database might be too large to fit on one disk volume of your server and so must use more than one file—a separate file on each disk volume. If many files are being used for the database, the files themselves are sometimes organized into separate file groups, with each group consisting of several individual files.
Each SQL Server database must also have at least one file for the transaction log, which stores all changes that are made to the database. If you are unfamiliar with the use of the SQL Server transaction log, please see my previous 10-Minute Solution, "Using SQL Server Recovery Models", for a more in-depth description.
1. Fully Backing Up the Whole Database:
Regardless of how many files your database uses, you can create a complete backup of your database with one simple command:
BACKUP DATABASE [dbname] to [backup_device]
For example,
BACKUP DATABASE pubs to disk = 'c:\mssql\backup\pubs.bak'
creates a complete backup of the pubs database using the file c:\mssql\backup\pubs.bak.
The database can remain online and accessible to users while this backup is being made. In order to take a consistent snapshot of the database, a copy of the transaction log is also included with the database backup.
In the backup file, SQL Server stores the names and locations of the files actually used in the database. Upon restoring the database, SQL Server recreates all the necessary files, as many as there might be. A database thus restored is equivalent to the point in time that the backup finished.
A complete database backup is very simple to execute and use in recovery. If your data doesn't change often, you might simply schedule a nightly full backup of your database. Even if you need more frequent backups, regularly scheduling a full database backup each hour might be sufficient (if your database is small enough).
2. Backing Up the Database One File at a Time:
A complete database backup is certainly a powerful and simple option. In the case of a very large database, however, a complete backup might simply take too long to be feasible.
Consider a database used in a data warehousing application. The database might easily approach several hundred gigabytes in size and, as such, take too long to back up in one operation. In such a case, SQL Server provides the option of backing up individual files or file groups.
For instance, this command will back up an individual file:
BACKUP DATABASE database_name
FILE = file_name
TO DISK = 'file_for_backup'
This command will back up all files in a particular group:
BACKUP DATABASE database_name
FILEGROUP = file_group_name
TO DISK = 'file_for_backup'
With these commands, you can set up a schedule where a different file or file group is backed up every evening, completing a full cycle in a week.
Besides shortening the length of time it takes to create a backup, a file backup can also make recovery quicker. If only a single file in your database has been lost, a file backup will allow you to simply restore that file. However, it is important to note that a file backup cannot be used by itself. In order for the database to be recovered to a consistent state (where all the files in the database represent the same moment in time), all transaction logs (see next section) made since the file backup was created must also be applied.
Listing 1 creates a test database with two file groups.
Following the CREATE statement are two backup commands.
The first backs up only the test1 file;
the second backs up all files in the primary file group.
create database test
on primary
(name = test1,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test1.mdf'),
(name = test2,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test2.ndf'),
filegroup group2
(name = test3,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test3.ndf'),
(name = test4,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test4.ndf')
log on
(name = test_log,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test_log.ldf')
First backup command:
backup database test
file = 'test1'
to disk = 'e:\test1.bak'
Second backup command:
backup database test
filegroup = 'primary'
to disk = 'e:\primary.bak'
3. Backing Up Only the Changes to the Database:
In addition to full backups, SQL Server provides two methods for backing up only the changes that have occurred to the database.
Transaction Log Backup:
This command creates a copy of all the transactions in the transaction log at the time the backup was started:
BACKUP TRAN [database_name] to disk = [file_name]
Once the backup is completed, all committed transactions are removed from the log. A typical backup plan utilizing transaction backups might be to make a full backup of the database once a night (or even once a week on larger databases) and back up the transaction logs as often as every ten minutes. To recover the database under this scheme, you would start from the last full backup and apply all the transaction log backups since.
This type of scheme suffers from one problem, however. You need the full backup and every transaction log backup made up to the point when you have to recover. For example, suppose your backup scheme consists of a full database backup every Saturday at midnight and transaction log backups every hour. If your database has a problem on Thursday at midnight, you would need to restore the full database backup, as well as the 120 transaction log backups made from Saturday through Thursday, to get up to date.
For this reason, SQL Server provides yet another method of backing up changes to the database that is used in conjunction with full database and transaction log backups.
4. Differential Backup:
A differential backup creates a copy of all the changes that have taken place in the database since the last full backup. The command is the same for a full database backup, with the addition of one clause:
BACKUP DATABASE [database_name] to disk = 'file_name' with differential
Now you can implement the following backup scheme: a full backup every Saturday, a differential backup every night, and a transaction log backup every hour. Once this scheme is in place, if you go down on Thursday evening, all you need to do is apply the full backup, the last differential backup (which would have been Wednesday evening), and all the transaction logs since—for a total of only 26 files.
This 10-Minute Solution covers the basics of the BACKUP command and the four types of backups that you can create. However, I haven't discussed some other additional features that SQL Server provides with this command, such as creating a backup device or password protection. Before implementing a backup plan, I suggest you perform additional research on these features by reading up on the BACKUP command in the Books Online manual. Additionally, you should remember to test your backup plan thoroughly by performing test restores on a regular basis.
Joe Lax has spent the last 10 years working in various database environments and has been a practicing DBA on all versions of SQL Server from version 4.2 onward. Joe is also a MCSE and an MCT. Recently, he has started to learn Oracle, which affords him no end of fun.
Restore a MSSQL Database
The syntax for using T-SQL commands is as follows:
RESTORE DATABASE { database_name | @database_name_var }
[ FROM <> [ ,...n ] ]
[ WITH
[ RESTRICTED_USER ]
[ [ , ] FILE = { file_number | @file_number } ]
[ [ , ] PASSWORD= { password | @password_variable } ]
[ [ , ] MEDIANAME= { media_name | @media_name_variable } ]
[ [ , ] MEDIAPASSWORD= { mediapassword | @mediapassword_variable } ]
[ [ , ] MOVE 'logical_file_name' TO 'operating_system_file_name' ]
[ ,...n ]
[ [ , ] KEEP_REPLICATION ]
[ [ , ] { NORECOVERY | RECOVERY | STANDBY =undo_file_name } ]
[ [ , ] { NOREWIND | REWIND } ]
[ [ , ] { NOUNLOAD | UNLOAD } ]
[ [ , ] REPLACE ]
[ [ , ] RESTART ]
[ [ , ] STATS [ =percentage ] ]
Example:
ALTER DATABASE MYPAY
SET MULTI_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE MYPAY
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE MYPAY
FROM disk = 'c:\abc.bak';
Note: to avoid Database in use Problem.
ALTER DATABASE MYPAY
SET MULTI_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE MYPAY
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
The article describes four different methods of backin up a SQL Server database; when to use them and why.
by Joe Lax, SQL Server Pro
When I started using SQL Server in version 4.2, backups were relatively simple. There were only two possibilities: a full backup or a transaction log backup. Starting with SQL Server 7, additional choices have proliferated. You now have four ways to back up your database.
If you are responsible for maintaining SQL Server databases, you need to be familiar with these various options and know when to apply each backup type. In this 10-Minute Solution, I show you the commands to execute each different kind of backup and discuss how to choose among the various options you have.
[THE PROBLEM]
How many different ways can you back up your SQL Server database?
[THE SOLUTION]
SQL Server provides four different methods for backing up your database:
- A full backup makes a complete backup of your database. You will almost always need to start your backup strategy with a full backup of your database.
- A file backup is useful when your database is so large that a full backup would take too long.
- A transaction log backup creates a copy of all changes made to the database that are currently stored in the transaction log.
- A differential backup stores all changes that have occurred to the database since the last full backup.
Components of a SQL Server Database
Before exploring each of the various options in backing up a SQL Server database, let's review how information is stored in one.
A SQL Server database stores data in one or more database files. While many databases only use a single file to store data, there are good reasons sometimes to split your data among several files. As an example, if you need the extra performance, you can store tables that are frequently used in their own separate files. By placing those files on separate disks, you avoid contention for disk access. Or your database might be too large to fit on one disk volume of your server and so must use more than one file—a separate file on each disk volume. If many files are being used for the database, the files themselves are sometimes organized into separate file groups, with each group consisting of several individual files.
Each SQL Server database must also have at least one file for the transaction log, which stores all changes that are made to the database. If you are unfamiliar with the use of the SQL Server transaction log, please see my previous 10-Minute Solution, "Using SQL Server Recovery Models", for a more in-depth description.
1. Fully Backing Up the Whole Database:
Regardless of how many files your database uses, you can create a complete backup of your database with one simple command:
BACKUP DATABASE [dbname] to [backup_device]
For example,
BACKUP DATABASE pubs to disk = 'c:\mssql\backup\pubs.bak'
creates a complete backup of the pubs database using the file c:\mssql\backup\pubs.bak.
The database can remain online and accessible to users while this backup is being made. In order to take a consistent snapshot of the database, a copy of the transaction log is also included with the database backup.
In the backup file, SQL Server stores the names and locations of the files actually used in the database. Upon restoring the database, SQL Server recreates all the necessary files, as many as there might be. A database thus restored is equivalent to the point in time that the backup finished.
A complete database backup is very simple to execute and use in recovery. If your data doesn't change often, you might simply schedule a nightly full backup of your database. Even if you need more frequent backups, regularly scheduling a full database backup each hour might be sufficient (if your database is small enough).
2. Backing Up the Database One File at a Time:
A complete database backup is certainly a powerful and simple option. In the case of a very large database, however, a complete backup might simply take too long to be feasible.
Consider a database used in a data warehousing application. The database might easily approach several hundred gigabytes in size and, as such, take too long to back up in one operation. In such a case, SQL Server provides the option of backing up individual files or file groups.
For instance, this command will back up an individual file:
BACKUP DATABASE database_name
FILE = file_name
TO DISK = 'file_for_backup'
This command will back up all files in a particular group:
BACKUP DATABASE database_name
FILEGROUP = file_group_name
TO DISK = 'file_for_backup'
With these commands, you can set up a schedule where a different file or file group is backed up every evening, completing a full cycle in a week.
Besides shortening the length of time it takes to create a backup, a file backup can also make recovery quicker. If only a single file in your database has been lost, a file backup will allow you to simply restore that file. However, it is important to note that a file backup cannot be used by itself. In order for the database to be recovered to a consistent state (where all the files in the database represent the same moment in time), all transaction logs (see next section) made since the file backup was created must also be applied.
Listing 1 creates a test database with two file groups.
Following the CREATE statement are two backup commands.
The first backs up only the test1 file;
the second backs up all files in the primary file group.
create database test
on primary
(name = test1,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test1.mdf'),
(name = test2,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test2.ndf'),
filegroup group2
(name = test3,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test3.ndf'),
(name = test4,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test4.ndf')
log on
(name = test_log,
filename = 'e:\mssqlserver\mssql$joelax2000_1\data\test_log.ldf')
First backup command:
backup database test
file = 'test1'
to disk = 'e:\test1.bak'
Second backup command:
backup database test
filegroup = 'primary'
to disk = 'e:\primary.bak'
3. Backing Up Only the Changes to the Database:
In addition to full backups, SQL Server provides two methods for backing up only the changes that have occurred to the database.
Transaction Log Backup:
This command creates a copy of all the transactions in the transaction log at the time the backup was started:
BACKUP TRAN [database_name] to disk = [file_name]
Once the backup is completed, all committed transactions are removed from the log. A typical backup plan utilizing transaction backups might be to make a full backup of the database once a night (or even once a week on larger databases) and back up the transaction logs as often as every ten minutes. To recover the database under this scheme, you would start from the last full backup and apply all the transaction log backups since.
This type of scheme suffers from one problem, however. You need the full backup and every transaction log backup made up to the point when you have to recover. For example, suppose your backup scheme consists of a full database backup every Saturday at midnight and transaction log backups every hour. If your database has a problem on Thursday at midnight, you would need to restore the full database backup, as well as the 120 transaction log backups made from Saturday through Thursday, to get up to date.
For this reason, SQL Server provides yet another method of backing up changes to the database that is used in conjunction with full database and transaction log backups.
4. Differential Backup:
A differential backup creates a copy of all the changes that have taken place in the database since the last full backup. The command is the same for a full database backup, with the addition of one clause:
BACKUP DATABASE [database_name] to disk = 'file_name' with differential
Now you can implement the following backup scheme: a full backup every Saturday, a differential backup every night, and a transaction log backup every hour. Once this scheme is in place, if you go down on Thursday evening, all you need to do is apply the full backup, the last differential backup (which would have been Wednesday evening), and all the transaction logs since—for a total of only 26 files.
This 10-Minute Solution covers the basics of the BACKUP command and the four types of backups that you can create. However, I haven't discussed some other additional features that SQL Server provides with this command, such as creating a backup device or password protection. Before implementing a backup plan, I suggest you perform additional research on these features by reading up on the BACKUP command in the Books Online manual. Additionally, you should remember to test your backup plan thoroughly by performing test restores on a regular basis.
Joe Lax has spent the last 10 years working in various database environments and has been a practicing DBA on all versions of SQL Server from version 4.2 onward. Joe is also a MCSE and an MCT. Recently, he has started to learn Oracle, which affords him no end of fun.
Restore a MSSQL Database
The syntax for using T-SQL commands is as follows:
RESTORE DATABASE { database_name | @database_name_var }
[ FROM <> [ ,...n ] ]
[ WITH
[ RESTRICTED_USER ]
[ [ , ] FILE = { file_number | @file_number } ]
[ [ , ] PASSWORD= { password | @password_variable } ]
[ [ , ] MEDIANAME= { media_name | @media_name_variable } ]
[ [ , ] MEDIAPASSWORD= { mediapassword | @mediapassword_variable } ]
[ [ , ] MOVE 'logical_file_name' TO 'operating_system_file_name' ]
[ ,...n ]
[ [ , ] KEEP_REPLICATION ]
[ [ , ] { NORECOVERY | RECOVERY | STANDBY =undo_file_name } ]
[ [ , ] { NOREWIND | REWIND } ]
[ [ , ] { NOUNLOAD | UNLOAD } ]
[ [ , ] REPLACE ]
[ [ , ] RESTART ]
[ [ , ] STATS [ =percentage ] ]
Example:
ALTER DATABASE MYPAY
SET MULTI_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE MYPAY
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
RESTORE DATABASE MYPAY
FROM disk = 'c:\abc.bak';
Note: to avoid Database in use Problem.
ALTER DATABASE MYPAY
SET MULTI_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE MYPAY
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Monday, March 30, 2009
【好文】怎样的人生没有白活
[Source]
作者:dengchun2006
读了十几年的书,认了上千的字。也写过数不清的信件和文章,今天提起笔来写自己的第一篇博客文章,语言文字竟跑的无影无踪了......,面对自己经常思索的人生,要说的话好多,却又无从说起。
做人有时很难堪,常常要等到蓦然回首,才会惊觉最渴望与之携手的人已另有怀抱,而自己也早已担着沉甸甸的责任。再怎么惊天动地的寻死觅活终是一场迟到,只徒然灼痛了自己伤害了别人......
及时行乐常常被认为是醉生梦死的颓废,以致于我们有些人总是苛待自己,似乎唯有不谈享乐才是积极的人生,人生多磨难:成长的坚辛,奋斗的不易,加之种种违反天性却又不得不恪守的规矩,构成了生存的严酷与无奈。唯有学会享乐,懂得享乐,才能真正理解人生的情趣与宝贵,才会因此更珍惜自己并珍惜这个世界。不要频频给自己制造痛苦,更不要以为痛苦一定有价值。生命的意义决不在于历尽艰难痛不欲生,而是要尝遍人间的甜蜜并为之甘愿同艰难作战。所以人们蓦然回首人生,发现自己错了,于是呼把希望寄托于渺茫的来世。
我不会愚蠢的对待自己生活,生命对我也许还很长,或许还有四五十年呢!干嘛非要把今生寄托于虚幻的来世呢!除了奋斗之外就是过自己随心所欲的生活,最重要的是心境快乐。
作者:dengchun2006
读了十几年的书,认了上千的字。也写过数不清的信件和文章,今天提起笔来写自己的第一篇博客文章,语言文字竟跑的无影无踪了......,面对自己经常思索的人生,要说的话好多,却又无从说起。
做人有时很难堪,常常要等到蓦然回首,才会惊觉最渴望与之携手的人已另有怀抱,而自己也早已担着沉甸甸的责任。再怎么惊天动地的寻死觅活终是一场迟到,只徒然灼痛了自己伤害了别人......
及时行乐常常被认为是醉生梦死的颓废,以致于我们有些人总是苛待自己,似乎唯有不谈享乐才是积极的人生,人生多磨难:成长的坚辛,奋斗的不易,加之种种违反天性却又不得不恪守的规矩,构成了生存的严酷与无奈。唯有学会享乐,懂得享乐,才能真正理解人生的情趣与宝贵,才会因此更珍惜自己并珍惜这个世界。不要频频给自己制造痛苦,更不要以为痛苦一定有价值。生命的意义决不在于历尽艰难痛不欲生,而是要尝遍人间的甜蜜并为之甘愿同艰难作战。所以人们蓦然回首人生,发现自己错了,于是呼把希望寄托于渺茫的来世。
我不会愚蠢的对待自己生活,生命对我也许还很长,或许还有四五十年呢!干嘛非要把今生寄托于虚幻的来世呢!除了奋斗之外就是过自己随心所欲的生活,最重要的是心境快乐。
Friday, March 27, 2009
Rounding Mechanism to the nearest multiple of 5 sen
[Link] - Rounding Mechanism
[Link] - Frequently Asked Questions on Rounding Mechanism
[Link] - Frequently Asked Questions on Rounding Mechanism
The table below illustrates how the Rounding Mechanism works:
Bill ends in sen | Round off to the nearest 5 sen | Total Amount of A Bill | |
Total amount before rounding (RM) | Total amount after rounding (RM) | ||
| 1,2 | Down | 82.01 82.02 | 82.00 |
| 3,4 | Up | 82.03 82.04 | 82.05 |
| 6,7 | Down | 82.06 82.07 | 82.05 |
| 8,9 | Up | 82.08 82.09 | 82.10 |
General guidelines of rounding
- The total amount of a bill (including goods and services subject to tax) that ends in 1, 2, 6 and 7 sen to be rounded downwards and 3, 4, 8 and 9 sen to be rounded upwards to the nearest multiple of 5 sen.
- Applicable to all over-the-counter payments, be it cash or non-cash.
- The Rounding Mechanism table must be clearly displayed at the point of sale to ensure customers are appropriately informed.
- Receipts / bills / invoices should feature the total amount before and after the rounding adjustment.
- The 1 sen coin shall continue to be legal tender.