English 中文(简体)
如何更新Katch?
原标题:How to update SQL Batch?
  • 时间:2011-11-08 17:48:52
  •  标签:
  • sql

在我的客户所在地,他们有一个数据库。 一旦我完成数据库的增量变化,我就编制了一个文件“QQ”的物体变更清单。

文字如下:

If sql object 1 present in database 
   DROP the SQL object 1
GO

create the SQL Object 1 

If sql object 2 present in database 
   DROP the SQL object 2

create the SQL Object 2

我已经放弃了现有目标,并重新提出。

现在这一批号可能含有一些错误。

我的要求是,如果档案中有任何错误的话。 未加固的锡克尔物体已重新分类。 它应当收回旧的q。

如果不存在错误,它就会产生所有Kingk物体。

由于“GO>,在中文本中,无法使用中文本中的运输。

如何解决这一问题?

问题回答

Don t use GO, 然后。 简单地将其从您的文字中删除,并在需要时添加<条码>BEGIN和<条码>。

BEGIN TRAN

   IF EXISTS Object1
   BEGIN
        DROP Object1;
   END 
   CREATE Object1;

   IF EXISTS Object2
   BEGIN
        DROP Object2;
   END 
   CREATE Object2;

COMMIT TRAN

通过DROP/CREATE修改数据库图示有许多问题:

  • it may loose data
  • it looses permissions and extended properties added to the objects dropped
  • cross object dependencies (eg. foreign keys) require a certain order of drop/create

通常最好是将物体从化学版本到化学版本。 这就要求你知道目前使用的是哪一种图形版本,但这个问题很容易被搁置(使用数据库扩展的财产,见)。 FCCC/SBI/2008/8。

回答你的问题,一种冷静的做法,就是把整个文字放在大的BEGIN TRAN/COMMIT中,但很少奏效:

对于这些参考书,我将重新采用一种更为简单、更安全的办法:在修改数据表之前,支持数据库。 如果任何事情都错了,则抄送本。 另一种做法是,可将数据库的缩略作为备份。 见。 如何:将数据库转至Snapshot数据库。

请注意,BEGIN TRAN/COMMIT可以跨过批次(例如,可通过多个<代码>GO分离),因此你的关切不是一个问题。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签