SQL Server

Small the safety that discusses MSSQL Server 2000 and management

Common ground is told,Data-base is to store the database of the data that has certain character.Normally,We differentiate the user of system of life data warehouse it is four kinds,The controller of data-base architect, data-base, person that use programming reachs the person that use commonly.Among them the management that data-base controller is in charge of Zhang date and safeguard,The access of the person that decide all data-base are used is restricted.Safety administration can say data-base is the job with data-base the mainest controller.The company level data-base that SQL Server is Microsoft,It is a function the powerful, data-base that uses easily,Can do safe mechanism conformity with the date of Zhang of the person that use of Windows NT/2000 directly.


So,After all what is safety administration?In short,Safety administration is to show the staff that joins a server to needing to ascend undertakes administrative.In using a program,We will be right of data-base of all kinds data of setting of the person that use operates attributive,It is the government that does Zhang date and password in using a program directly normally,But this kind of practice needs compose programme controll.And the figure that SQL Server has kind, easy operation uses an interface,Can manage the access of the person that use to SQL Server conveniently attributive.


Safety administration of SQL Server can be divided for 3 administrative levels,Namely post door, the manages as specific as join database attributive of data-base is opposite with the person that use the operation attributive of a join data-base part.Below,We will be done in the light of these 3 administrative levels define.

One, post door
The account that the person that any need access the use of SQL Server all needs to a group of servers are approbated and password.SQL Server support records pattern 2 kinds,One kind for Windows test and verify,Another kind is SQL Server test and verify.Former should establish as corresponding as Windwos NT/2000 post in SQL Server only door,The account that when the person that let use ascends Windows NT/2000, uses can be mutual and as corresponding as the account in SQL Server,Can hook up smoothly SQL Server,From this,The conformity that we finished mechanism of safe to Windows NT/2000 government.


Next,Data-base controller is on Windows NT post date,Can add group of groups in Windows NT in SQL Server directly,Become a post thereby door.


Through afore-mentioned operations,Windows NT ascends group of members in the group to all can join SQL Server.If member of the some in this groups of groups does not allow his to ascend,enter SQL Server,Can be in the individual account of this member sets SQL Server lieutenant general to be accessed to refuse.If install SQL Server in Windows 95, Windows 98 or Windows Me,Cannot use means of Windows test and verify.


If use SQL Server test and verify,The person that those who want join SQL Server must is to use in SQL Server establishs the Zhang number name that publishs and code,The account of these Zhang date and password and Windows NT/2000 has nothing to do.

Two, the attributive that manages as specific as join database
Establishing post door hind,The person that use can enter SQL Server in,But the limits of authority that does not have specific data-base of join SQL Server on behalf of the person that use,Must be opposite the person that use or group group of operation limits of authority that set pair of SQL Server.The to data-base operation attributive in SQL Server can divide those who be the operation attributive of server oneself and data-base to access attributive.To the operation of SQL Server attributive can be installed by server part,The access of data-base attributive can is opposite with the person that use by the part the access of individual form attributive will install.So,What is there to differ between server part and part?


1. Server part
SQL Server system is built-in part of 8 kinds of servers (group of groups in can envisioning the role into date of Windows NT Zhang) ,It cannot be changed or add newly.The person that should use to some or group after part of group setting good server,The limits of authority that its have place of this server part.Server part is each management of SQL Server the job tries to classify,If build Zhang date and data-base backup,wait,It and data-base role are different,The operation attributive that latter is pair of individual data-base.

The attributive that we list place of part of 8 kinds of servers is had simply.System Administrators states systematic manager is executable any movements.Security Administrators expresses to run post door.Each parameter that Server Administrators expresses to install SQL Server.Setup Administrators states concerned Replication(is duplicate) setting and administrative expansion put a program beforehand.Process Administrators expresses all execution to manage SQL Server medium program.Disk Administrators Express to manage data-base file.Database Administrators expresses to build and change data-base property.The government that Bulk Insert Administrators represents to be operated to executable Bulk Insert.


2. Part
SQL Server is built-in part of 10 kinds of data-base,It cannot be changed or delete,But can add a part to individual data-base.If give the person that use to have the data-base owner limits of authority in built-in part,The whole operation that it owns this data-base counterpoises.The detailed attributive of each part shows the rest can consult the Bol(of SQL Server namely SQL Server Books Online) ,Through inquiring key word Roles,The project that enters caption to be Roles,Have the complete specification that includes built-in server part and data-base part among them,In this not much give uncecessary details.Those who need an attention is,Be opposite the person that use set all sorts of parts respectively (the each person that use or group group can have a variety of parts) hind,The limits of authority that it has market of all part couplet,But if among them some part operates power to some (if counterpoise to the Select of some form) installed refuse,It will lose this limits of authority,In other words,Reject attributive excel to grant limits of authority.

Three, of the component in data-base access attributive
The management to SQL Server and can join the attributive of specific data-base,The server part that supplies by SQL Server place and data-base part basically can accord with us major demand.Additional,Can be opposite directly the person that use or group group setting accesses attributive to the component in data-base individually,These access attributive individually to have Select, Insert, Update, Delete, Exec and Dri,Among them Exec and Dri represent the executive attributive to putting a program beforehand and the limits of authority of test and verify to form effectiveness respectively.When doing direct attributive to install,The person that we also can be aimed at special use (when like built-in data-base the part cannot be satisfied) ,Of course,If use,compare a long time with the user of attributive means,The data-base part that can add to accord with demand,Or the person that use these is attributed to some group of groups first on Windows NT/2000,Set limits of authority to this groups of groups again,Such doing more square facilitating management and safeguard.


Except afore-mentioned content,When moving actually,The author sums up a the following to suggest to data-base guards a pass safely.
1. Unless necessary,Manage otherwise as far as possible with Windows test and verify can join the use person of SQL Server,The safe mechanism with integrated Windows NT/2000.
2. The server part that be apt to uses SQL Server and data-base part function.
3. Be apt to uses SQL Server add close function.

SQL Server offerred post date, network to transmit, fictitious watc
h adds close function with what put a program beforehand.Among them the password of Zhang date is added close be set beforehand,And the data is transmitted to be able to use SSL means to undertake adding between the network close,Should start what this function must start Net-library to add close function,The CA function that should cooperate Windows 2000 at the same time,Finish in server end and client side setting,Thereby both sides is before transmission data,Can add in SSL close hind reentry is transmitted all right.In because fictitious watch and the definition that put a program beforehand are,protecting existence system data in order to with the price clearly marked to express,If want to mix fictitious watch,put a program to add beforehand close,In ENTerprise Manager when its are built the setting adds close option or can narrate with Alter will install add close.

4. After systematic setup ends,Be sure to change the Sa code that establishs beforehand,Lest has other the SQL Server that compulsory ” of ” of the person that use manages you.

Comments Off more...

How to restore when SQL Server database breaks down

The state that any database systems cannot avoid to break down,Although you used Clustered,Double machine heats up equipment… still cannot eradicate completely the only place breakdown in the system,What is more,the rather that to major user,Cannot bear so costly hardware invests.So,When the system breaks down,How to restore original valuable data to become an all in all issue.

When restore,The data file that optimal circumstance is you and log file are in good condition nondestructive,Need Sp_attach_db only so,Add data file to new database can,Perhaps be in stop machine when all data file (must Master waits) Copy falls to also go to original method,Do not recommend such way commonly nevertheless,Sp_attach_db is better,Although bother a lot of.

But,When general database breaks down, the system is may not can have time to wait for half-baked general affairs and dirty page those who write disk,Such circumstance Sp_attach_db can fail.So,Sent expectation to make a good disaster reinstate a plan at DBA.Plan according to your refreshment,Reductive and newest complete backup,Increment backs up or clerical log backs up,If if log of your mobile general affairs still can be read,coming out next,Congratulation you!You are OK and reductive the condition to the front of break down.

Common unit is the DBA that does not have full-time,If do not have practicable to back up,May be the time that backs up recently more too ages ago and cause not acceptability data loss,And log of your mobile general affairs also is in the position that cannot use,That is the most troubled condition.

Unfortunate is,General database breaks down is as a result of what memory subsystem causes,And such circumstance is almost impossible to practicable log is used at what restore.
So was forced to try these scheme.Of course,It is a requirement at least your data file is existence,If if data file, log file is mixed,backup was done not have,Do not look for me,You can go up to building top sing ” god ah,Save save me ” .

Above all,You can try Sp_attach_single_file_db,The data file that tries to restore you,Although can restore possibility is not large,If if this database just carried out a Checkpoint,passing,Succeed likely still.

If you had been done not have to the luck that has tombola bill,The most important database did not expect like you go on Attach in that way,Not crestfallen,Still have other program.

We can try to build a Log afresh,Install the database first for Emergency Mode,The Status of Sysdatabases states for 32768 the database is in this condition.

Nevertheless systematic watch is cannot change casually,Install first
Use Master
GoSp_configure ‘allow Updates’ , 1Reconfigure With Override
Go
NextUpdate Sysdatabases Set Status = 32768 Where Name = ‘%26lt;db_name%26gt;’
Now,Of Buddha of invocatory full deity bless,Build file of a Log afresh.Successful opportunity is quite great still,The system can approbate you to build the daily record that establish commonly.If did not report what is wrong,Can loosen now at a heat.

Although data was to restore,But do not think the thing calculates,finished,The work that having is missing for certain,Original data gets possibly also a few attaint.

Start SQL Server afresh first,The database that checks you next.
Set odd user pattern first,Do Dbcc nextSp_dboption ‘%26lt;db_name%26gt;’ , ‘single User’ , ‘true’
DBCC CHECKDB(‘%26lt;db_name%26gt;’ )
If do not have what big question to be able to change database position,went back,The modification option that writes down so that did not forget to express the system is put out.Update Sysdatabases Set Status = 28 Where Name = ‘%26lt;db_name%26gt;’- – of course your database condition may not be this,The value with him appropriate instead.Also can use Sp_resetstatusGoSp_configure ‘allow Updates’ , 0Reconfigure With Override
Go
Checkdb when the report has the possibility a few mistakes,These erroneous data you may be forced to discard.Checkdb has option of a few kinds of rehabilitate,Oneself are looked at with,Nevertheless you may be returned finally is use REPAIR_ALLOW_DATA_LOSS,Complete all repair.Chekcdb can not complete all repair,We need further repair,To each with DBCC CHECKTABLE the watch makes an inspection.
The list of the watch can be used get inside Sysobjects,OBJECTPROPERTY be IsTable is all seek an inspection,Basically can solve a problem so,If return report error,Try to check data Select Into to another piece of watch.
After these finished,Wait for process of all index, view, memory, trigger to be built afresh.DBCC DBREINDEX perhaps can give you a few help.

Comments Off more...

The memory course that runs about be on duty

The requirement of Director Bt is on duty management Ask as follows

1 a group of alignment N individual,Have 4 kinds of parts,Leader,Fellow,Aunt,Driver.The part presses N individual him basis to discharge fine line orderly

2 is on duty requirement:Week lead 1 times to weekday be on duty a driver is on duty;arrive weekday every night a fellow is on duty;Saturday weekday 2 aunts are on duty afternoon in the morning;Holiday leads a driver 1 times everyday a fellow in the morning afternoon 2 aunts

Alignment of 3 requirement but additions and deletions checks this,Personnel order can be adjusted,When alignment happening changes,Be on duty the watch is updated automatically

Personnel of alignment of 4 requirement can transfer not to enter epicycle sort to listing medium personnel at any time (be away on official business or ask for leave) below annulus continue to press alignment order sort,After personnel transfers,Alignment takes sb’s place automatically ahead

5 relief. . .

Build 2 lists

1 Watching

[Datetime] date [Weekday] week [2id of aunt of 1id [female2] of aunt of Id [female1] of fellow of Leaderid] leader Id [maleid] [Id of Driverid] driver [Mark] remarks

2 Watching_person

[Ordercode] personnel number [part of personnel of Id [part] of Personid] personnel [whether does Leave] leave [Mark] remarks

Part is personnel part 1 leader 3 aunts of 2 fellow 4 drivers

Need when new alignment arises finer from tomorrow the following be on duty arrangement is expressed (it is 30 days here) ,Conduct the position of rest that has queued up by the part memory process next (get namely begin to discharge a driver to begin to discharge fellow aunt from the a fewth from the a fewth. . . )


Create Proc Proc_WatchingSetup
– - the position of rest that parameter is four kinds of parts
@leader Int,
@Male Int,
@Female Int,
@Driver IntAs

Declare @i Int – - tallyDeclare @j IntDeclare @PersonID IntDeclare @weekday IntDeclare @InsertPoint DatetimeDeclare @msg Char(20)

Set @i=1Set @j=1

- – general affairs begins
Begin Tran ReChange
- – delete the following tomorrow record (alignment already was changed delete previously)Delete From Watching Where [Datetime]%26gt;GetDate()

If (@@error %26lt%26gt;0)
BeginRollback TranSet @msg=’error1′ReturnEnd

- – the date of 30 days after reinserting and weekWhile @i%Ǻlt;=30BeginInsert Watching (Datetime, weekDay) Values (dateadd(day, @i, {fn Curdate()}) , datepart(weekday, dateadd(day, @i, {fn Curdate()})) ) Set @i=@i+1End

If (@@error! =0)
BeginRollback TranSet @msg=’error2′ReturnEnd

- – begin to use cursor

Set @j=1

- – / / / / numerate by order queueing up above all the leader’s alignment

Declare Cur_watchingPerson Scroll Cursor ForSelect Personid From Watching_person Where Part=1 Order By OrderCode Asc

Open Cur_watchingPerson

- – move to begin the positionFetch Absolute @leader From Cur_watchingPerson Into @PersonIDIf @@fetch_status=-1Fetch First From Cur_watchingperson Into @PersonID

Set @i=1

While @i%26lt;=30Begin

While @j%26lt;=7- – the longest likelihood is 1 person inserts 7 daysBegin Update Watching Set LeaderId=@PersonID Where [datetime]=(dateadd(day, @i, {fn Curdate()}) ) If (@@error! =0)
BeginRollback TranSet @msg=’error3′ReturnEnd
– - if be not worth,7 days exit circular substitution to on the weekendSelect @weekday=datepart(weekday, dateadd(day, @i, {fn Curdate()}) )Set @i=@iƯIf (@weekday=1)Break
End

Set @j=1
Fetch Next From Cur_watchingperson Into @PersonID
– - if exceed border to turn round alignment the firstIf @@fetch_status=-1Fetch First From Cur_watchingperson Into @PersonIDEnd

Close Cur_watchingPersonDeallocate Cur_watchingPerson

- – / / / / / / / / / / / / driver very leader just the sameDeclare Cur_watchingPerson4 Scroll Cursor ForSelect Personid From Watching_person Where Part=4 Order By OrderCode Asc

Open Cur_watchingPerson4

- – move to begin the positionFetch Absolute @driver From Cur_watchingPerson4 Into @PersonIDIf @@fetch_status=-1Fetch First From Cur_watchingperson4 Into @PersonID

Set @i=1

While @i%26lt;=30BeginWhile @j%26lt;=7- – the longest likelihood is 1 person inserts 7 daysBegin Update Watching Set DriverId=@PersonID Where [datetime]=(dateadd(day, @i, {fn Curdate()}) ) If (@@error! =0)
Begin
– - Rollback TranSet @msg=’error3′ReturnEnd

Select @weekday=datepart(weekday, dateadd(day, @i, {fn Curdate()}) )Set @i=@i+1If (@weekday=1)Break
End

Set @j=1Fetch Next From Cur_watchingperson4 Into @PersonID
– - if exceed border to turn round alignment the firstIf @@fetch_status=-1Fetch First From Cur_watchingperson4 Into @PersonIDEnd

Close Cur_watchingPerson4Deallocate Cur_watchingPerson4

- – / / / / / / / / / / /

- – fellow everyday evening shift of 1 person value is relatively easyDeclare Cur_watchingPerson2 Scroll Cursor ForSelect Personid From Watching_person Where Part=2 Order By OrderCode Asc

Open Cur_watchingPerson2

- – move to begin the positionFetch Absolute @male From Cur_watchingPerson2 Into @PersonIDIf @@fetch_status=-1Fetch First From Cur_watchingperson2 Into @PersonID

Set @i=1

While @i%26lt;=30Begin
Update Watching Set MaleId=@PersonID Where [datetime]=(dateadd(day, @i, {fn Curdate()}) ) If (@@error! =0)
BeginRollback TranSet @msg=’error3′ReturnEnd
Set @i=@iƯ

Fetch Next From Cur_watchingperson2 Into @PersonID
– - if exceed border to turn round alignment the firstIf @@fetch_status=-1 Fetch First From Cur_watchingperson2 Into @PersonID
End

Close Cur_watchingPerson2Deallocate Cur_watchingPerson2

- – the aunt is weekly 2 people are worth six weekday day shiftDeclare Cur_watchingPerson3 Scroll Cursor ForSelect Personid From Watching_person Where Part=3 Order By OrderCode Asc

Open Cur_watchingPerson3

Fetch Absolute @female From Cur_watchingPerson3 Into @PersonIDIf @@fetch_status=-1Fetch First From Cur_watchingperson3 Into @PersonID

Set @i=1

While @i%26lt;=30Begin

Select @weekday=[weekday] From Watching Where [datetime]=(dateadd(day, @i, {fn Curdate()}) )

– - judgement has the half talent on the weekend to be on duty only arrange 2 peopleIf @weekday=7 Or @weekday=1Begin

– - insert the firstUpdate Watching Set Female1=@PersonID Where [datetime]=(dateadd(day, @i, {fn Curdate()}) )
If (@@error! =0)
BeginRollback TranSet @msg=’error3′ReturnEnd

Fetch Next From Cur_watchingperson3 Into @PersonID
– - if exceed border to turn round alignment the firstIf @@fetch_status=-1 Fetch First From Cur_watchingperson3 Into @PersonID
– - insert the secondUpdate Watching Set Female2=@PersonID Where [datetime]=(dateadd(day, @i, {fn Curdate()}) )
If (@@error! =0)
Begin
– - Rollback TranSet @msg=’error3′ReturnEnd

End
Set @i=@i+1Fetch Next From Cur_watchingperson3 Into @PersonID
– - if exceed border to turn round alignment the firstIf @@fetch_status=-1 Fetch First From Cur_watchingperson3 Into @PersonID
End

Close Cur_watchingPerson3Deallocate Cur_watchingPerson3

Commit Tran


When above is changed for alignment, generate new be on duty the memory process of arrangement

The member that other such as stipulates holiday adjusts a person very much the same welcomes to criticize point out mistakes so that they can be corrected

Comments Off more...

  • Copyright © 1996-2010 sql tutorial for beginners,sql server tutorial,sql tutorial pdf,sql tutorials. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress