MySQL Command Prompt

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

Create a new database

CREATE DATABASE BooksDBase;

2
New cards

Select the new database

USE BooksDBase;

3
New cards

Create a table

CREATE TABLE BooksTable ( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(100), author VARCHAR(100), price INT(8);

4
New cards

Insert data

INSERT INTO BooksTable (title, author, price) VALUES ('Harry Potter and the Sorcerers Stone', 'J.K. Rowling', 10), ('To Kill a Mockingbird', 'Harper Lee', 9), ('The Great Gatsby', 'F. Scott Fitzgerald', 12);

5
New cards

Retrieve all books

SELECT * FROM BooksTable;

6
New cards

Retrieve books with price > 10

SELECT * FROM BooksTable WHERE price > 10;

7
New cards

Update price of "To Kill a Mockingbird" to 11

UPDATE BooksTable SET price = 11 WHERE title = 'To Kill a Mockingbird';

8
New cards

Delete the book "The Great Gatsby"

DELETE FROM BooksTable WHERE title = 'The Great Gatsby';

9
New cards

Retrieve all books in ascending order by title

SELECT * FROM BooksTable ORDER BY title ASC;

10
New cards

Delete the table

DROP TABLE BooksTable;