database-scripts

Most efficient and easiest way to back up a portion of specific tables hourly

隐身守侯 提交于 2019-12-11 06:01:04
问题 I need to create an hourly .SQB backup file of some specific tables, each filtered with a WHERE clause, from a SQL Server database. As an example, I need this data: SELECT * FROM table1 WHERE pk_id IN (2,5,7) SELECT * FROM table2 WHERE pk_id IN (2,5,7) SELECT * FROM table3 WHERE pk_id IN (2,5,7) SELECT * FROM table4 WHERE pk_id IN (2,5,7) The structure of the tables on the source database may change over time, e.g. columns may be added or removed, indexes added, etc. One option is to do some

how to get DB backup script from Remote Server in MySQL using command-line utility?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 17:13:23
问题 Can anybody tell me that how to get DB backup script from Remote Server in MySQL using command-line utility? I'm using a command as follows, but not working: C:\>mysqldump -h <server ip> -u <user-id> -p <password> <db name> > E:\dumpfilename.sql 回答1: The syntax for the password is wrong. You need to write the password immediately after the -p , without a space. That's why the password is interpreted as the database name. Write this instead: C:\>mysqldump -h <server ip> -u <user-id> -p

Create database using script at the default path?

徘徊边缘 提交于 2019-12-03 06:28:56
问题 I've generated a script of a database in SQL Server 2008. The generated script has the hardcoded path of where the database would be created. I don't want this path to be hardcoded, I want this path to use the default of the database engine the script is running on. Here is the small portion of the script: CREATE DATABASE [POS] ON PRIMARY ( NAME = N'POS', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\POS.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED,

How to partition an oracle table by a date column?

情到浓时终转凉″ 提交于 2019-11-30 17:29:59
问题 I have a table in oracle: CREATE TABLE transaction ( id INT NOT NULL, accountnumber VARCHAR NOT NULL, stmtvaluedate DATE NOT NULL, ... ) And I want to partition this table by the stmtvaluedate column. My goal is to create a new partition after a month have passed. Is there any good script, for it? Or I have to create static numbers of partitions? The best would be: if a month have passed, a new partition will be created automatically. Can anyone give me an example about how to partition a

Generate script in SQL Server Management Studio

陌路散爱 提交于 2019-11-26 22:21:07
If I have a table with data in a database in SQL Server, how can I generate a script that will create the table and add the data too? If I right click on the table then select Script Table As > Create to > File , that generates a script to just create the table without the data. What I need is a script that creates the table and adds the data that is already existing in the table or 2 separate scripts, one that creates the table and one that adds the data. Here what you have to do: right click the database (not the table) and select tasks --> generate scripts Next --> select the requested

Generate script in SQL Server Management Studio

对着背影说爱祢 提交于 2019-11-26 08:20:34
问题 If I have a table with data in a database in SQL Server, how can I generate a script that will create the table and add the data too? If I right click on the table then select Script Table As > Create to > File , that generates a script to just create the table without the data. What I need is a script that creates the table and adds the data that is already existing in the table or 2 separate scripts, one that creates the table and one that adds the data. 回答1: Here what you have to do: right