重命名表后更新时无效的对象名称

时间:2016-12-05 12:48:39

标签: sql database ssms sql-server-2016

尝试重命名表并使用它时有一个非常奇怪的问题 我有一个名为 oldTable 的表格,并将其重命名为 newTable
我可以使用

在此表上成功使用 select
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="mutationextract_pr" attributeFormDefault="qualified" elementFormDefault="qualified"
    targetNamespace="http://www.w3.org/2001/XMLSchema"   

    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <!--<xs:import location="MECommonFields.xsd" namespace="http://www.cisco.com/AXL/API/8.0"></xs:import>-->
  <xs:include schemaLocation="MECommonFields.xsd"></xs:include>
  <xs:element name="mutationextract_pr">
    <xs:complexType>
      <xs:sequence>
        <!--<xs:element name="documentversion" type="versiontype" minOccurs="1" maxOccurs="1"></xs:element>-->
        <xs:element name="header" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="formcaption" type="formcaptiontype" minOccurs="1" maxOccurs="1" />
              <xs:element name="documentname" type="documentnametype" minOccurs="1" maxOccurs="1" />
              <xs:element name="districtlabel" type="districtlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="district" type="districttype" minOccurs="1" maxOccurs="1" />
              <xs:element name="taluklabel" type="taluklabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="taluk" type="taluktype" minOccurs="1" maxOccurs="1" />
              <xs:element name="hoblilabel" type="hoblilabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="hobli" type="hoblitype" minOccurs="1" maxOccurs="1" />
              <xs:element name="villagelabel" type="villagelabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="village" type="villagetype" minOccurs="1" maxOccurs="1" />
              <xs:element name="mrnumberlabel" type="mrnumberlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="mrnumber" type="mrnumbertype" minOccurs="1" maxOccurs="1" />
              <xs:element name="transactionyearlabel" type="transactionyearlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="transactionyear" type="transactionyeartype" minOccurs="1" maxOccurs="1" />
              <xs:element name="transactionnumberlabel" type="transactionnumberlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="transactionnumber" type="transactionnumbertype" minOccurs="1" maxOccurs="1" />
              <xs:element name="sourcelabel" type="sourcelabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="source" type="sourcetype" minOccurs="1" maxOccurs="1" />
              <xs:element name="mutationlabel" type="mutationlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="mutationtype" type="mutationtypetype" minOccurs="1" maxOccurs="1" />
              <xs:element name="acquisitionlabel" type="acquisitionlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="acquisitiontype" type="acquisitiontypetype" minOccurs="1" maxOccurs="1" />
              <xs:element name="numberlabel" type="ordernumberlabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="number" type="ordernumbertype" minOccurs="1" maxOccurs="1" />
              <xs:element name="datelabel" type="orderdatelabeltype" minOccurs="1" maxOccurs="1" />
              <xs:element name="date" type="orderdatetype" minOccurs="1" maxOccurs="1" />
              <xs:element name="extentmeasurement" type="extentmeasurementtype" minOccurs="1" maxOccurs="1" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="mutatedownerheader" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="surveynoheader" type="xs:string" minOccurs="1" maxOccurs="1" />
              <xs:element name="ownerheader" type="xs:string" minOccurs="1" maxOccurs="1" />
              <xs:element name="extentsheader" type="xs:string" minOccurs="1" maxOccurs="1" />
              <xs:element name="remarksheader" type="xs:string" minOccurs="1" maxOccurs="1" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="mutatedownerdetails" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="owners" minOccurs="1" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="surveyno" type="xs:string" minOccurs="1" maxOccurs="1" />
                    <xs:element name="landrevenue" type="xs:string" minOccurs="1" maxOccurs="1" />
                    <xs:element name="owner" minOccurs="1" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="mutatedownername" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="rights" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="liabilities" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="govtrestriction" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="govtrestrictiontype" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="govtrestrictioncategory" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="govtrestrictiondate" type="xs:string" minOccurs="1" maxOccurs="1" />
                          <xs:element name="extents" type="extentstype" minOccurs="1" maxOccurs="1" />
                          <xs:element name="jointwithprevious" type="xs:string" minOccurs="1" maxOccurs="1" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="footer" type="footertype" minOccurs="1" maxOccurs="1" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

但是当我尝试使用 update 时:

SELECT * FROM database.dbo.newTable;

我收到以下错误:

UPDATE database.dbo.newTable SET foo = bar where id = 1;

看起来名称oldTable存储在某个地方,并在这里被某种引用使用。尝试更新时,它会在ssms和raw php + sql上发生 有人有任何想法吗?

1 个答案:

答案 0 :(得分:2)

重命名表不会更新为表定义的任何触发器(或其他任何位置的引用),因此您需要手动更新任何触发器或其他依赖项以反映新名称。