Skip to content

Instantly share code, notes, and snippets.

@hayesch19
Last active September 13, 2019 18:57
Show Gist options
  • Save hayesch19/12a2985fcd2fe0569753ff2ab2f73475 to your computer and use it in GitHub Desktop.
Save hayesch19/12a2985fcd2fe0569753ff2ab2f73475 to your computer and use it in GitHub Desktop.
company_database> CREATE TABLE employees (full_name TEXT, job_title TEXT, salary IN
................. T, phone_extension INT, full_time TEXT, part_time TEXT, id SERIAL PRIMARY KEY);
CREATE TABLE
Time: 0.009s
company_database> SELECT * FROM employees;
+-------------+-------------+----------+-------------------+-------------+-------------+------+
| full_name | job_title | salary | phone_extension | full_time | part_time | id |
|-------------+-------------+----------+-------------------+-------------+-------------+------|
+-------------+-------------+----------+-------------------+-------------+-------------+------+
SELECT 0
Time: 0.020s
Time: 0.001s
company_database> SELECT * FROM employees;
+-------------+----------------------+----------+-------------------+-------------+-------------+------+
| full_name | job_title | salary | phone_extension | full_time | part_time | id |
|-------------+----------------------+----------+-------------------+-------------+-------------+------|
| Chris Hayes | Digital Overlord | 90000 | 100 | yes | no | 1 |
| Wade Wilson | Chief Biscuit Dunker | 70000 | 100 | yes | no | 2 |
| Lazy Lynn | Digital Marketer | 70000 | 100 | no | yes | 3 |
+-------------+----------------------+----------+-------------------+-------------+-------------+------+
SELECT 3
Time: 0.018s
company_database> INSERT INTO employees (full_name, job_title, salary, phone_extension, full_time, part_time)
................. VALUES ('Peter Parker', 'Software Developer', 45000, 100, 'no', 'yes');
INSERT 0 1
Time: 0.003s
company_database> DELETE FROM employees WHERE full_name='Lazy Lynn';
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
DELETE 1
Time: 0.002s
company_database> UPDATE employees Set full_time='yes', part_time='no' WHERE part_time='yes';
UPDATE 1
Time: 0.001s
company_database> SELECT * FROM employees;
+--------------+----------------------+----------+-------------------+-------------+-------------+------+
| full_name | job_title | salary | phone_extension | full_time | part_time | id |
|--------------+----------------------+----------+-------------------+-------------+-------------+------|
| Chris Hayes | Digital Overlord | 90000 | 100 | yes | no | 1 |
| Wade Wilson | Chief Biscuit Dunker | 70000 | 100 | yes | no | 2 |
| Peter Parker | Software Developer | 45000 | 100 | yes | no | 5 |
+--------------+----------------------+----------+-------------------+-------------+-------------+------+
SELECT 3
Time: 0.019s
company_database> SELECT full_name, phone_extension FROM employees WHERE full_time='yes';
+--------------+-------------------+
| full_name | phone_extension |
|--------------+-------------------|
| Chris Hayes | 100 |
| Wade Wilson | 100 |
| Peter Parker | 100 |
+--------------+-------------------+
SELECT 3
Time: 0.017s
company_database> UPDATE employees Set salary=50000 WHERE job_title='Software Developer';
UPDATE 1
Time: 0.002s
company_database> ALTER TABLE employees ADD COLUMN parking_spot_number varchar(10);
You're about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
ALTER TABLE
Time: 0.002s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment