Is there a way to tell whether an Alter statement made changes to what was already there?

For example if I have a view that says XYZ and I use an alter statement to alter it to the same exact thing (XYZ) is there a way to tell that as opposed to an alter statement that made a change from the original?

asked 17 Dec '10, 20:26

Siger%20Matt's gravatar image

Siger Matt
3.3k5672101
accept rate: 15%

Everything gets recorded in the transaction log, if that helps... dbtran lets you look at the log.

(20 Dec '10, 13:30) Breck Carter

DDL statements don't have return values (except the error codes when they fail).

I guess you just would have to compare the object's definition before and after the ALTER statement, e.g. compare for views whether sysview.view_def has changed. The same would apply to ALTER TABLE with (identically) altered or renamed columns or constraints and the according catalog tables.

Note that for all objects with "source code" (like view or procedure definitions) the actual SQL statement is typically stored in a "source" column in the according system tables - at least if the option preserve_source_format is set (as default).

In my experience, those "source definitions" are better suited for comparisons because different SA versions might store the parsed definitions of identical objects somewhat differently. As a consequence, when comparing the reload files of migrated databases, I often notice differences in the parsed definitions w.r.t. line breaks, position of "end if" statements and the like. - However, when comparing the "source definitions", those artificial differences should not appear.

permanent link

answered 18 Dec '10, 20:38

Volker%20Barth's gravatar image

Volker Barth
40.2k361549822
accept rate: 34%

edited 20 Dec '10, 11:34

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×10

question asked: 17 Dec '10, 20:26

question was seen: 1,547 times

last updated: 03 Jan '11, 12:22