generated from Code-Institute-Org/gitpod-full-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusing-insert.txt
92 lines (76 loc) · 3.88 KB
/
using-insert.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
mysql> INSERT INTO MediaType (Name)
-> VALUES ("Test Media 1");
Query OK, 1 row affected (0.04 sec)
mysql> SELECT * MediaType;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MediaType' at line 1
mysql> SELECT * FROM MediaType;
+-------------+-----------------------------+
| MediaTypeId | Name |
+-------------+-----------------------------+
| 1 | MPEG audio file |
| 2 | Protected AAC audio file |
| 3 | Protected MPEG-4 video file |
| 4 | Purchased AAC audio file |
| 5 | AAC audio file |
| 6 | Test Media 1 |
+-------------+-----------------------------+
6 rows in set (0.00 sec)
mysql> INSERT INTO Album (Title, ArtistId)
-> VALUES ("Boy", 150);
Query OK, 1 row affected (0.02 sec)
mysql> SELECT AlbumId FROM Album WHERE Title = "Boy";
+---------+
| AlbumId |
+---------+
| 348 |
+---------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT MediaTypeId FROM MediaType WHERE Name = "Protected AAC audio file";
+-------------+
| MediaTypeId |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)
mysql>
mysql> SELECT GenreId FROM Genre WHERE Name = "Rock";
+---------+
| GenreId |
+---------+
| 1 |
+---------+
1 row in set (0.00 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice)
-> VALUES ("I Will Follow", 348, 2, 1, "U2", 220000, 1234, 0.99);
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("Twilight", 348, 2, 1, "U2", 210000, 1234, 0.99);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("An Cat Dubh", 348, 2, 1, "U2", 110000, 1234, 0.99);
Query OK, 1 row affected (0.03 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("Into the Heart", 348, 2, 1, "U2", 200000, 1234, 0.99);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("Out of Control", 348, 2, 1, "U2", 100000, 1234, 0.99);
Query OK, 1 row affected (0.03 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("Stories for Boys", 348, 2, 1, "U2", 150000, 1234, 0.99);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("The Ocean", 348, 2, 1, "U2", 175000, 1234, 0.99);
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) VALUES ("A Day Without Me", 348, 2, 1, "U2", 185000, 1234, 0.99);
Query OK, 1 row affected (0.03 sec)
mysql>
mysql> Insert into Track (Name, AlbumId, GenreId, Composer, Milliseconds, Bytes, UnitPrice)
-> values("Extra Track", 348, 1, "U2", 290000, 1234, 0.99);
ERROR 1364 (HY000): Field 'MediaTypeId' doesn't have a default value
mysql> Insert into Track (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice) values("Extra Track", 348,2, 1, "U2", 290000, 1234, 0.99);
Query OK, 1 row affected (0.02 sec)
mysql>
mysql> INSERT INTO Track
-> (Name, AlbumId, MediaTypeId, GenreId, Composer, Milliseconds, Bytes, UnitPrice)
-> VALUES
-> ("Another Time, Another Place", 348, 2, 1, "U2", 210000, 1234, 0.99),
-> ("The Electric Co.", 348, 2, 1, "U2", 200000, 1234, 0.99),
-> ("Shadows and Tall Trees", 348, 2, 1, "U2", 150000, 1234, 0.99);
Query OK, 3 rows affected (0.03 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> NOTEE;