1. Union,union All
SELECT E_name from Employees_china
UNION
SELECT E_name from Employees_usa
By default, the UNION operator chooses a different value. If duplicate values are allowed, use UNION all.
2. Create a table
CREATE TABLE Persons
(
id_p int not NULL,
LastName varchar (255) is not NULL,
FirstName varchar (255),
Address varchar (255),
City varchar (255),
CONSTRAINT uc_PersonID UNIQUE (Id_P,LastName)
)
If you need to name a unique constraint and define a UNIQUE constraint for multiple columns
3. Create a UNIQUE constraint in the "id_p" column when the table has been created
ALTER TABLE Persons
ADD CONSTRAINT uc_PersonID UNIQUE (Id_P,LastName)
If you want to revoke a UNIQUE constraint
ALTER TABLE Persons
DROP CONSTRAINT uc_PersonID
4.CREATE TABLE Persons
(
id_p int not NULL PRIMARY KEY
,
LastName varchar (255) is not NULL,
FirstName varchar (255),
Address varchar (255),
City varchar (255)
)
5.SQL FOREIGN KEY Constraint
CREATE TABLE Orders
(
id_o int not NULL PRIMARY KEY,
OrderNo int not NULL,
Id_P int FOREIGN KEY REFERENCES Persons(Id_P)
)
, the id_p column in Orders points to the id_p column in the Persons table.
The "id_p" column in the "Persons" table is the PRIMARY KEY in the Persons table.
The "id_p" column in the Orders table is the FOREIGN KEY in the Orders table.
The FOREIGN KEY constraint is used to prevent actions that disrupt the connection between tables.
Http://www.w3s.com.cn/sql/sql_foreignkey.asp
SQL Beginner Tutorial Learning (iv)