Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/victor0089/sql
SQL practice
https://github.com/victor0089/sql
sql sql-server sqlalchemy sqlite sqlite3
Last synced: 10 days ago
JSON representation
SQL practice
- Host: GitHub
- URL: https://github.com/victor0089/sql
- Owner: victor0089
- License: mit
- Created: 2023-10-17T08:50:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-18T08:06:54.000Z (over 1 year ago)
- Last Synced: 2024-11-24T11:14:37.458Z (2 months ago)
- Topics: sql, sql-server, sqlalchemy, sqlite, sqlite3
- Homepage:
- Size: 197 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL
Comments for your SQL file:
```bash
$ cat my_script.sql
-- 3 first students in the Batch ID=3
-- because Batch 3 is the best!
SELECT id, name FROM students WHERE batch_id = 3 ORDER BY created_at DESC LIMIT 3;
```
Install MySQL 8.0 on Ubuntu 20.04 LTS
```bash
$ sudo apt update
$ sudo apt install mysql-server
python
$ mysql --version
mysql Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
$
```
Connect to your MySQL server:
```bash
$ sudo mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.25-0ubuntu0.20.04.1 (Ubuntu)Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the
```
current input statement.
```bash
mysql>
mysql> quit
Bye
$
```
Use “container-on-demand” to run MySQL
In the container, credentials are root/rootAsk for container Ubuntu 20.04
* Connect via SSH
* OR connect via the Web terminal
* In the container, you should start MySQL before playing with it:
```bash
$ service mysql start
* Starting MySQL database server mysqld
$
$ cat 0-list_databases.sql | mysql -uroot -p
Database
information_schema
mysql
performance_schema
sys
$
```
In the container, credentials are root/root
How to import a SQL dump
```bash
$ echo "CREATE DATABASE hbtn_0d_tvshows;" | mysql -uroot -p
Enter password:
$ curl "https://s3.amazonaws.com/intranet-projects-files/holbertonschool-higher-level_programming+/274/hbtn_0d_tvshows.sql" -s | mysql -uroot -p hbtn_0d_tvshows
Enter password:
$ echo "SELECT * FROM tv_genres" | mysql -uroot -p hbtn_0d_tvshows
Enter password:
id name
1 Drama
2 Mystery
3 Adventure
4 Fantasy
5 Comedy
6 Crime
7 Suspense
8 Thriller
$
```