-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Concepts: Keywords #4747
base: main
Are you sure you want to change the base?
Add Concepts: Keywords #4747
Changes from all commits
24c5e52
9702ca8
0f1ac31
f75cc1f
d2eb154
5b193ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,122 @@ | ||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||
Title: 'Keywords' | ||||||||||||||||||||||||||||||||||
Description: 'MySQL keywords are predefined words that have special meaning in the SQL language and are used to perform various operations within the database.' | ||||||||||||||||||||||||||||||||||
Subjects: | ||||||||||||||||||||||||||||||||||
- 'Code Foundations' | ||||||||||||||||||||||||||||||||||
- 'Data Science' | ||||||||||||||||||||||||||||||||||
- 'Data Visualization' | ||||||||||||||||||||||||||||||||||
Tags: | ||||||||||||||||||||||||||||||||||
- 'MySQL' | ||||||||||||||||||||||||||||||||||
- 'Data' | ||||||||||||||||||||||||||||||||||
CatalogContent: | ||||||||||||||||||||||||||||||||||
- 'learn-sql' | ||||||||||||||||||||||||||||||||||
- 'paths/analyze-data-with-sql' | ||||||||||||||||||||||||||||||||||
- 'paths/data-science' | ||||||||||||||||||||||||||||||||||
- 'paths/data-science-foundations' | ||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
MySQL **keywords** are predefined words that have special meaning in the SQL language. They are used to perform various operations within the database, such as creating tables, inserting data, querying the database, updating records, and more. Examples of MySQL keywords include SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, and ALTER. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Importance and Usage | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Keywords define the structure and syntax of SQL queries. They help organize the commands in a way that the MySQL database can interpret and execute. Each keyword performs a specific function such as selecting data (`SELECT`), inserting new records (`INSERT`), or modifying existing records (`UPDATE`). | ||||||||||||||||||||||||||||||||||
Using keywords ensures that your SQL queries are standarized, this enhances readability and maintainability of your code. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Syntax | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the entire Syntax section. I know I suggested adding it in the last review, and I apologize for any inconvenience this may cause. Replace it with the following section:
Feel free to edit and improve as needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the end, please refer to the official documentation of MySQL KEYWORDS for the comprehensive list. |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### CREATE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
CREATE TABLE table_name ( | ||||||||||||||||||||||||||||||||||
column1 datatype, | ||||||||||||||||||||||||||||||||||
column2 datatype, | ||||||||||||||||||||||||||||||||||
... | ||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### INSERT | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
INSERT INTO table_name (column1, column2, ...) | ||||||||||||||||||||||||||||||||||
VALUES (value1, value2, ...); | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### SELECT | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
SELECT column1, column2, ... | ||||||||||||||||||||||||||||||||||
FROM table_name | ||||||||||||||||||||||||||||||||||
WHERE condition; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### UPDATE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
UPDATE table_name | ||||||||||||||||||||||||||||||||||
SET column1 = value1, column2 = value2, ... | ||||||||||||||||||||||||||||||||||
WHERE condition; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### DELETE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
DELETE FROM table_name | ||||||||||||||||||||||||||||||||||
WHERE condition; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Example | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### CREATE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
CREATE TABLE employees ( | ||||||||||||||||||||||||||||||||||
id INT AUTO_INCREMENT PRIMARY KEY, | ||||||||||||||||||||||||||||||||||
first_name VARCHAR(50), | ||||||||||||||||||||||||||||||||||
last_name VARCHAR(50), | ||||||||||||||||||||||||||||||||||
position VARCHAR(100), | ||||||||||||||||||||||||||||||||||
salary DECIMAL(10, 2), | ||||||||||||||||||||||||||||||||||
hire_date DATE | ||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### INSERT | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
INSERT INTO employees (first_name, last_name, position, salary, hire_date) | ||||||||||||||||||||||||||||||||||
VALUES ('John', 'Doe', 'Software Engineer', 75000.00, '2024-05-25'); | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### SELECT | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
SELECT first_name, last_name | ||||||||||||||||||||||||||||||||||
FROM employees | ||||||||||||||||||||||||||||||||||
WHERE position = 'Software Engineer'; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### UPDATE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
UPDATE employees | ||||||||||||||||||||||||||||||||||
SET salary = 80000.00 | ||||||||||||||||||||||||||||||||||
WHERE id = 1; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### DELETE | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```SQL | ||||||||||||||||||||||||||||||||||
DELETE FROM employees | ||||||||||||||||||||||||||||||||||
WHERE id = 1; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Comment on lines
+70
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest combining the use cases of different keywords into one comprehensive example. Like this:
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
## Best Practices | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
**Consistent formatting**: Always write keywords in uppercase for better readability | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
**Proper naming conventions**: Avoid using keywords as names for tables or coumns. If necessary use, use backticks to avoid syntax errors. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
**Comprehensive understanding**: Familiarize yourself with the list of reserved keywors to avoid unintentional errors in yout SQL queries. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Check the complete list [MySQL Documentation](https://dev.mysql.com/doc/refman/8.0/en/keywords.html) for more details! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine and condense these statements. Remove the "Importance and Usage" section and ensure the whole statement is free of redundancy.