--SELECT INTO table2 from table1--INSERT INTO table2 select table1 explanationCreate Tableuserinformation (IDint Identity(10001,1), UIDint, namenvarchar( -), ageint, Birthdaynvarchar( -), Addressnvarchar( -), Countrynvarchar( -), Provincenvarchar( -), Citynvarchar( -), remarknvarchar( $), --constraint Df_uid Foreign key (UID) references Q_user (UID))Select * fromuserinformationAlter TableuserinformationAdd constraintDf_uidForeign Key(UID)ReferencesQ_user (UID)--assigns the Q_user query as a table to the table (with structure and data) UserInformation (requires that the table does not exist)SelectUid,uname intoUserInformation fromQ_user--inserting data from a q_user query into a userinformationInsert intoUserInformation (Uid,name)SelectUid,uname fromQ_user--Multi-Table Query--Fully connectedSelect * fromUserinformation,q_user--Internal ConnectionSelect * fromQ_user b,userinformation awhereA.uid=B.uid--Inner Connection (two tables to intermediate connections, as long as the same)Select * fromQ_user aInner JoinUserInformation b--inner can be omitted onA.uid=B.uid--left connection (based on left table, connection right with connection data, not NULL)Select * fromQ_user a Left JoinUserInformation b--inner can be omitted onA.uid=B.uid--Right connection (based on the right table)Select * fromQ_user a Right JoinUserInformation b--inner can be omitted onA.uid=B.uid--self-connect (just connect yourself to a table and take a different alias)Select * fromQ_user a Right JoinQ_user b--inner can be omitted onA.uid=B.uid----------------Union----------Union unites two tables of data, and the same data shows only one of them--UNION All unites two tables, regardless of the data--either union or union all, the column names of the preceding and following tables must be consistent and the text column cannot appear-----------------Select * fromQ_userUnion Select * fromQ_userSelect * fromQ_userUnion All Select * fromQ_user
SQL Server from getting started proficient in----table replication and multi-table connection queries