mojaSymfonia FORUM https://forum.mix-soft.pl/ |
|
przeniesienie bazy danych sql https://forum.mix-soft.pl/viewtopic.php?f=16&t=3071 |
Strona 1 z 1 |
Autor: | darekm [ 2011-04-21, 09:07 ] |
Tytuł: | przeniesienie bazy danych sql |
problem symfonia forte zainstalowana na dysku c baza danych tez na c: kończy sie miejsce na dysku c: dysk d: praktycznie pusty czy mozńa w prosty sposób np przekopiować bazę danych na d: ? np przenosząc cała kartotekę z baza? |
Autor: | rafal [ 2011-04-21, 13:13 ] |
Tytuł: | |
Attaching and Detaching Databases on SQL Server By Alexander Chigrik Introduction If you need to move a database, or database file to another server or disk, and you do not want to backup the database, copy the backup on another server, and then re-create the database from the backup, you can use the sp_detach_db and sp_attach_db system stored procedures to detach the database and then attach it again. Detaching and attaching databases can be used when you want to move the database files to a different physical disk from the disk that has run out of disk space and you want to expand the existing file rather than add a new file to the database on another disk. To move a database using detach and attach, you should make the following steps:
•Move the database file(s) to the desired location on another server or disk. •Attach the database specifying the new location of the moved file(s). After detaching, the database will be removed from SQL Server but will be intact within the data and transaction log files that compose the database. You can use these data and transaction log files to attach the database to any instance of SQL Server, including the server from which the database was detached. After attaching, the database will be available in exactly the same state it was in when it was detached. Detaching a Database To detach an SQL Server 2000 database, you can use the sp_detach_db system stored procedure. This stored procedure can also run UPDATE STATISTICS on all tables before detaching. The syntax for sp_detach_db system stored procedure is as follows: Kod: sp_detach_db [ @dbname = ] 'dbname' [ , [ @skipchecks = ] 'skipchecks' ] In the above, the parameters to the stored procedure are as follows:
•[@skipchecks =] 'skipchecks' The 'skipchecks' parameter indicates will be can UPDATE STATISTICS run or skipped. The 'skipchecks' is nvarchar(10), a default value is NULL. If 'skipchecks' is true, UPDATE STATISTICS is skipped. If 'skipchecks' is false, UPDATE STATISTICS is run. The following example detaches the pubs database and runs UPDATE STATISTICS on all tables before detaching: Kod: EXEC sp_detach_db 'pubs', 'false' Attaching a Database When you attach a database, you must specify at least the name and physical location of the primary data file. If one or more of the database files have changed location since the database was detached, you must specify the name and physical location of these files in addition to the primary file. To attach SQL Server 2000 database, you can use the sp_attach_db system stored procedure. The syntax for sp_attach_db system stored procedure is as follows: Kod: sp_attach_db [ @dbname = ] 'dbname', [ @filename1 = ] 'filename_n' [ ,...16 ] In the above command:
•[@filename1 =] 'filename_n' is the database file name. filename_n is nvarchar(260), a default value is NULL. There can be up to 16 file names specified. This is the example to attach the pubs database which contain two files pubs.mdf and pubs_log.ldf from the C:\MSSQL\Data directory: Kod: EXEC sp_attach_db @dbname = 'pubs', @filename1 = 'C:\MSSQL\Data\pubs.mdf', @filename2 = 'C:\MSSQL\Data\pubs_log.ldf' Attaching a Single-File Database A single-file database is a database that has only one data file. When a database comprises only one data file , the database can be attached to an instance of SQL Server 2000 without using the transaction log file. When the data file will be attached, SQL Server will create a new transaction log file automatically. To attach a single-file database, you can use the sp_attach_single_file_db system stored procedure. The syntax for sp_attach_single_file_db system stored procedure is as follows: Kod: sp_attach_single_file_db [ @dbname = ] 'dbname' , [ @physname = ] 'physical_name'
•[@physname =] 'phsyical_name' is the database file name. 'phsyical_name' is nvarchar(260), a default value is NULL. This is the example to attach only one data file of the pubs database from the C:\MSSQL\Data directory: Kod: EXEC sp_attach_single_file_db @dbname = 'pubs', @physname = 'C:\MSSQL\Data\pubs.mdf' Troubleshooting Lost Users When you move a database to another server and there are existing users in the detached database, you can lose users after attaching the database on the new server. For example, if you move the Sales database from the Product server to the Test server (for the test purposes) and the user Alex exists in the Sales database, you should manually link the relationship between the Alex user and the appropriate login on the Test server. You can use the sp_change_users_login system stored procedure to link the specified user in the current database to the appropriate login. The following example links the user Alex in the current database to the Alex login: Kod: EXEC sp_change_users_login 'Update_One', 'Alex', 'Alex' See SQL Server Books Online to get more information about the sp_change_users_login stored procedure. Tekst pochodzi ze strony http://www.databasejournal.com/features ... Server.htm |
Autor: | wrob [ 2011-04-21, 14:23 ] |
Tytuł: | |
Moze prosciej..... :) Wyjdz z FK i innych, zatrzymaj commona jesli masz Wejdz do SQL management studio znajdz tam te swoją baze kliknij w nia prawym wybierz properties /files - zapamietaj gdzie sa pliki tej bazy...... potem znow w nia prawym - poszukaj detach - wykonaj.... wejdz do katalogu z plikami bazy (zazwyczaj to 2 pliki ldf i mdf) przenies je na inny dysk np D: Wroc do SQL manag - na galezi databases - kliknij prawym - wybierz attach - podaj gdzie przegrales te pliki.... No i najwazniejsze - zrob backup - zanim zaczniesz to powyższe robic :) :) :) |
Strona 1 z 1 | Strefa czasowa UTC+1godz. [letni] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |