Database Lib7 2nd, 3 questions (creating indexes and triggers)

Source: Internet
Author: User

2. Establish an appropriate index for the tables created above, and describe the process of indexing (can or write SQL). It is required to establish an index on the Sno, PNo fields in the SPJ, and an index for the combination of (PNo, Jno). is the index on SNO and pno a clustered index or a nonclustered index? Why?

Attached code:

1 Create Index  on SPJ (SNo) 2 Create Index  on SPJ (PNo) 3 Create Clustered Index  on SPJ (SNo, PNo);

3. Please teach yourself the trigger section of the Chinese book P160, and with the help of SQL Server, create a trigger that, when inserting data into table p,

Insert this data into a new table of your own, and the structure of the table is consistent with the P-label (append).

Attached code:

1 Create TriggerInsert_trigger2      onBranch3      for Insert4  as 5     Print 'Data Backup ...'6     if(object_id('Bankup','U') is  not NULL)7         Insert  intoBankupSelect *  fromBranch;8     Else 9         Select *  intoBankup fromBranch;Ten     Print 'Data Backup Complete' One Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.