Created
July 23, 2024 07:35
-
-
Save arialdomartini/73c17aa0baa0c289e75f40fb63e41f54 to your computer and use it in GitHub Desktop.
dolt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create database getting_started; | |
use getting_started; | |
create table employees ( | |
id int, | |
last_name varchar(255), | |
first_name varchar(255), | |
primary key(id)); | |
create table teams ( | |
id int, | |
team_name varchar(255), | |
primary key(id)); | |
create table employees_teams( | |
team_id int, | |
employee_id int, | |
primary key(team_id, employee_id), | |
foreign key (team_id) references teams(id), | |
foreign key (employee_id) references employees(id)); | |
show tables; | |
call dolt_add('teams', 'employees', 'employees_teams'); | |
call dolt_commit('-m', 'created initial schema'); | |
select * from dolt_log; | |
insert into employees values | |
(0, 'Sehn', 'Tim'), | |
(1, 'Hendriks', 'Brian'), | |
(2, 'Son','Aaron'), | |
(3, 'Fitzgerald', 'Brian'); | |
insert into teams values | |
(0, 'Engineering'), | |
(1, 'Sales'); | |
select * from employees; | |
select *from teams; | |
select * from employees_teams; | |
insert into employees_teams(employee_id, team_id) values | |
(0,0), | |
(1,0), | |
(2,0), | |
(0,1), | |
(3,1); | |
select first_name, last_name, team_name from employees | |
join employees_teams on (employees.id=employees_teams.employee_id) | |
join teams on (teams.id=employees_teams.team_id) | |
where team_name='Engineering'; | |
select * from dolt_status; | |
select * from dolt_diff_employees_teams; | |
call dolt_commit('-am', 'Populated tables with data'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment