(
id int primary key,
c_name char(10)
)
create table my_order
(
order_id int primary key,
order_date datetime,
c_id int foreign key references customer(id)
)
insert into customer values(1, 'bob'),(2,'mark')
insert into my_order values(1, '2017-12-6', 1),(2,'2017-12-1',2)
select c.c_name, o.order_date from customer as c inner join my_order as o on c.id=o.order_id;
ALTER TABLE my_order DROP constraint fk_1;
ALTER TABLE my_order
ADD CONSTRAINT FK_2
FOREIGN KEY (c_id) REFERENCES customer(id);
https://katieandemil.academy/sql-insert-date-datetime-using-t-sql-in-ms-sql-server
https://www.w3schools.com/sql/func_sqlserver_datediff.asp
https://www.w3schools.com/sql/func_sqlserver_datepart.asp
https://www.w3schools.com/sql/sql_datatypes.asp
No comments:
Post a Comment