“SQL Fremdschlüssel” Code-Antworten

So fügen Sie fremde Schlüsselbeschränkungen in SQL hinzu

ALTER TABLE 'table_name'
ADD CONSTRAINT 'constraint_name' FOREIGN KEY 'foreign_key' REFERENCES 'column_name'('primary_key');
Lux

Änderungstabelle Fügen Sie Spalte und Fremdschlüssel MySQL hinzu

ALTER TABLE database.table
  ADD COLUMN columnname INT DEFAULT(1),
  ADD FOREIGN KEY fk_name(fk_column) REFERENCES reftable(refcolumn) ON DELETE CASCADE;
Open Owl

SQL Fremdschlüssel

create table Jobs(
job_id number not null,
job_title varchar(30),
min_salary number,
max_salary number
);
create table job_history(
employee_id number not null,
start_date date,
end_date date,
job_id number not null,
department_id number
);
alter table jobs add constraint pk_jobs primary key(job_id);
alter table job_history add constraint fk_job foreign key(job_id) references jobs(job_id);
Fierce Ferret

Unbekannter Schlüssel

USE Organization
CREATE TABLE Employee_Office
(
Id INT PRIMARY KEY IDENTITY(1,1),
Emp_Id int FOREIGN KEY REFERENCES Employee(Id),
Office_Id int FOREIGN KEY REFERENCES Office(Id)
)
Adorable Armadillo

SQL Fremd Schlüsselbeschränkungen

CREATE TABLE Orders (
  order_id INT PRIMARY KEY,
  customer_id int REFERENCES Customers(id)
);
SAMER SAEID

Unbekannter Schlüssel

USE Organization
CREATE TABLE Employee
(
Id INT PRIMARY KEY IDENTITY(1,1),
Name VARCHAR (50) NOT NULL,
Age INT,
Gender VARCHAR (50),
Dep_Id int FOREIGN KEY REFERENCES Department(Id),
Insur_Id int FOREIGN KEY REFERENCES Insurance(Id)
)
Adorable Armadillo

Ähnliche Antworten wie “SQL Fremdschlüssel”

Fragen ähnlich wie “SQL Fremdschlüssel”

Weitere verwandte Antworten zu “SQL Fremdschlüssel” auf Sql

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen