1、建立測試表;
create table company(companyId number, companyName varchar2(20), contacts varchar2(20));
create table users(userId number, companyId number, userName varchar2(20), userAge number, address varchar2(20));
2、插入測試資料;
insert into company values (1,"騰訊科技","馬化騰");
insert into company values (2,"微軟公司","鮑威爾");
insert into company values (3,"新浪科技","小明" );
insert into users values (1,1,"jack",23 , "上海");
insert into users values (2,1,"jack2", 23, "上海");
insert into users values (3,2,"jack3", 23, "上海");
insert into users values (4,2,"jack4", 23, "上海");
insert into users values (5,3,"jack5", 23, "上海");
insert into users values (6,3,"jack6", 23, "上海");
3、查詢表中資料;
select * from users;
4、編寫sql,關聯兩張表;select * from users t , company b where t.companyid = b.companyid and t.companyid = 1;
1、建立測試表;
create table company(companyId number, companyName varchar2(20), contacts varchar2(20));
create table users(userId number, companyId number, userName varchar2(20), userAge number, address varchar2(20));
2、插入測試資料;
insert into company values (1,"騰訊科技","馬化騰");
insert into company values (2,"微軟公司","鮑威爾");
insert into company values (3,"新浪科技","小明" );
insert into users values (1,1,"jack",23 , "上海");
insert into users values (2,1,"jack2", 23, "上海");
insert into users values (3,2,"jack3", 23, "上海");
insert into users values (4,2,"jack4", 23, "上海");
insert into users values (5,3,"jack5", 23, "上海");
insert into users values (6,3,"jack6", 23, "上海");
3、查詢表中資料;
select * from users;
4、編寫sql,關聯兩張表;select * from users t , company b where t.companyid = b.companyid and t.companyid = 1;