1. Description: copy a table (only copy structure, source table name: A, new table name: B)
SQL: Select * into B from a where 1 <> 1;
2. Description: copy a table (copy data, source table name: A, target table name: B)
SQL: insert into B (a, B, c) Select D, E, F from B;
3. Description: displays the article, Submitter, and last reply time.
SQL: select a. Title, A. username, B. adddate
From table ,(
Select max (adddate) adddate
From table where table. Title = A. Title) B
4. Description: External join query (table name 1: A, table name 2: B)
SQL: select a. a, a. B, A. C, B. C, B. D, B. f
From a left out join B on A. A = B. C;
5. Note: Five minutes ahead of schedule reminder
SQL: Select *
From schedule
Where datediff (''minute '', F Start Time, getdate ()> 5
6. Note: two associated tables are used to delete information that is not in the secondary table.
SQL: delete from Info
Where not exists (
Select *
From infobz
Where info. INFID = infobz. INFID );
7. Note :--
SQL: select a. Num, A. Name, B. upd_date, B. prev_upd_date
From Table1, (select X. Num, X. upd_date, Y. upd_date prev_upd_date
From (select num, upd_date, inbound_qty, stock_onhand
From Table2
Where to_char (upd_date, ''yyyy/mm'') =
To_char (sysdate, ''yyyy/mm'') X,
(Select num, upd_date, stock_onhand
From Table2
Where to_char (upd_date, ''yyyy/mm'') =
To_char (to_date (to_char (sysdate, ''yyyy/mm '')
| ''/01'', ''yyyy/MM/dd'')-1, ''yyyy/mm'') y,
Where X. num = Y. Num (+) and X. inbound_qty
+ Nvl (Y. stock_onhand, 0) <> X. stock_onhand) B
Where a. num = B. Num;
8. Note :--
SQL: Select *
From studentinfo
Where not exists (select * from student where studentinfo. ID = student. ID)
And system name = ''" & strdepartmentname &"''
And Major name = ''" & strprofessionname &"''
Order by gender, place of origin, total score of the college entrance examination;