[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572795-105":53,"doc-detail-572795-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","mysql-cheat-sheet","MySQL Cheat Sheet","","MySQL Cheat Sheet provides practical, command-focused guidance for common relational database tasks. It explains how to connect to a MySQL server, create and manage databases and tables, and modify table structures with ALTER TABLE. The guide includes core data operations such as INSERT, UPDATE, and DELETE, plus examples for querying with SELECT, WHERE filtering, joins, grouping, and aggregation. It also covers casting values to different data types and uses examples for string and text filtering.",{"@graph":63,"@context":122},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":51,"@type":70,"position":76},"https://docshare.wps.com/template/general/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/mysql-cheat-sheet/572795/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/mysql-cheat-sheet/572795.png","ImageObject",442,249,{"name":88,"@type":89},"pixelkiddo","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-19","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":79},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114,118],{"name":105,"@type":106,"acceptedAnswer":107},"How do you connect to a MySQL server and select a database?","Question",{"text":108,"@type":109},"Use the mysql command-line client with username and password, then run USE database_name to select the target database. Examples include mysql -u [username] -p and mysql -u [username] -p [database].","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"What SQL commands are used to create and manage databases and tables?",{"text":113,"@type":109},"CREATE DATABASE creates a database, SHOW DATABASES lists them, and USE switches context. For tables, CREATE TABLE defines structure, SHOW TABLES lists tables, and DESCRIBE table_name displays column information. DROP DATABASE and DROP TABLE remove objects.",{"name":115,"@type":106,"acceptedAnswer":116},"How do you query data with filtering, grouping, and aggregation?",{"text":117,"@type":109},"Use SELECT with WHERE for filtering, and add GROUP BY for grouping. Aggregation functions like COUNT, AVG, MIN, MAX, and SUM operate within groups, optionally combined with HAVING and ORDER BY.",{"name":119,"@type":106,"acceptedAnswer":120},"How can you change table structures or convert value types in MySQL?",{"text":121,"@type":109},"ALTER TABLE supports renaming tables and columns, adding or dropping columns, and modifying column data types. Use the CAST() function to convert a value to types such as CHAR, DATE, DECIMAL, SIGNED/UNSIGNED, TIME, YEAR, or JSON.","https://schema.org",{"og:url":78,"og:type":124,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":126,"canonical":78},"index,follow",{"doc_id":128,"site_id":56},572795,1792083967,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":88,"user_avatar":133,"doc_module":9,"category_id":50,"category_name":51,"doc_title":59,"doc_description":61,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":79,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":73,"language":139,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":61,"update_tm":143,"read_time":9},962090883892,"https://ap-avatar.wpscdn.com/avatar/e00115db34f3e0f11b?x-image-process=image/resize,m_fixed,w_180,h_180&k=1790152879550218658","MySQL Cheat Sheet  \nMySQL is a popular open-source relational database management system known for its ease of use and scalability. Sometimes, you will need a little help while working on a project. That's why we created this MySQL Cheat Sheet.  \nInstructions for installing MySQL are available at: [https://dev. mysql.com](https://dev. mysql.com)  \nCONNECTING TOA MYSQL SERVER  \nConnect to a MySQL server with a username and a password using the mysql command-line client.  \nMySQL will prompt for the password: mysql -u [username] -p  \nTo connect to a specific database on a MySQL server using a username and a password:  \nmysql -u [username] -p [database]  \nTo export data using the mysqldump tool:  \nmysqldump -u [username] -p \\[database] > data_backup.sql  \nTo exit the client: quit or exit  \nFor a full list of commands:  \nhelp  \nCREATING AND DISPLAYING DATABASES  \nTo create a database:  \nCREATE DATABASE zoo;  \nTo list all the databases on the server:  \nSHOW DATABASES;  \nTo use a specified database:  \nUSE zoo;  \nTo delete a specified database:  \nDROP DATABASE zoo;  \nTo list all tables in the database:  \nSHOW TABLES;  \nTo get information about a specified table:  \nDESCRIBE animal;  \nIt outputs column names, data types, default values, and more about the table.  \nCREATING TABLES  \nTo create a table:  \nCREATE TABLE habitat ( id INT ,  \nname VARCHAR (64)  \n) ;  \nUse AUTO_INCREMENT to increment the ID automatically with each new record. An AUTO_INCREMENT column must be defined as a primary or unique key:  \nCREATE TABLE habitat (  \nid INT PRIMARY KEY AUTO_INCREMENT , name VARCHAR (64)  \n) ;  \nTo create a table with a foreign key: CREATE TABLE animal (  \nid INT PRIMARY KEY AUTO_INCREMENT ,  \nname VARCHAR (64) , species VARCHAR (64) , age INT , habitat_id INT ,  \nFOREIGN KEY (habitat_id) REFERENCES habitat (id)  \n) ;  \nMODIFYING TABLES  \nUse the ALTER TABLE statement to modify the table structure.  \nTo change a table name:  \nALTER TABLE animal RENAME pet;  \nTo add a column to the table: ALTER TABLE animal  \nADD COLUMN name VARCHAR (64) ;  \nTo change a column name: ALTER TABLE animal  \nRENAME COLUMN id TO identifier;  \nTo change a column data type: ALTER TABLE animal  \nMODIFY COLUMN name VARCHAR (128) ;  \nTo delete a column: ALTER TABLE animal DROP COLUMN name;  \nTo delete a table:  \nDROP TABLE animal;  \nQUERYING DATA  \nTo select data from a table, use the SELECT command. An example of a single-table query:  \nSELECT species , AVG(age) AS average_age FROM animal  \nWHERE id ! = 3  \nGROUP BY species HAVING AVG(age) > 3 ORDER BY AVG(age) DESC;  \nAn example of a multiple-table query: SELECT [city.name](city.name) , [country.name](country.name)[ ](country.name)FROM city  \n[INNER | LEFT | RIGHT] JOIN country ON [city.country_id = country.id](city.country_id = country.id);  \nUse +, -, *, / to do some basic math.  \nTo get the number of seconds in a week:  \nSELECT 60 * 60 * 24 * 7 ; - - result: 604800  \nAGGREGATION AND GROUPING  \n AVG (expr) − average value of expr for the group.  \n COUNT (expr) − count of expr values within the group.  \n MAX(expr) − maximum value of expr values within the group.  \n MIN (expr) − minimum value of expr values within the group.  \n SUM (expr) − sum of expr values within the group.  \nTo count the rows in the table:  \nSELECT COUNT(* )  \nFROM animal;  \nTo count the non-NULL values in a column:  \nSELECT COUNT(name)  \nFROM animal;  \nTo count unique values in a column:  \nSELECT COUNT(DISTINCT name)  \nFROM animal;  \nGROUP BY  \nTo count the animals by species:  \nSELECT species , COUNT(id) FROM animal  \nGROUP BY species;  \nTo get the average, minimum, and maximum ages by habitat: SELECT habitat_id , AVG(age) ,  \nMIN(age) , MAX(age) FROM animal  \nGROUP BY habitat_id;  \nINSERTING DATA  \nTo insert data into a table, use the INSERT command: INSERT INTO habitat VALUES  \n(1 , 'River ' ) ,(2 , ' Forest ' ) ;  \nYou may specify the columns in which the data is added. The remaining columns are filled with default values or NULLs. INSERT INTO","cbCais2oO0V5BzsT","https://ap.wps.com/l/cbCais2oO0V5BzsT","pdf",98548,"English","# Connecting to a MySQL Server\n# Creating and Displaying Databases\n# Creating Tables\n# Modifying Tables\n# Querying Data\n# Aggregation and Grouping\n# Inserting Data\n# Updating and Deleting Data\n# Casting\n# Text Functions\n# Filtering the Output\n# Text Operators","[{\"question\":\"How do you connect to a MySQL server and select a database?\",\"answer\":\"Use the mysql command-line client with username and password, then run USE database_name to select the target database. Examples include mysql -u [username] -p and mysql -u [username] -p [database].\"},{\"question\":\"What SQL commands are used to create and manage databases and tables?\",\"answer\":\"CREATE DATABASE creates a database, SHOW DATABASES lists them, and USE switches context. For tables, CREATE TABLE defines structure, SHOW TABLES lists tables, and DESCRIBE table_name displays column information. DROP DATABASE and DROP TABLE remove objects.\"},{\"question\":\"How do you query data with filtering, grouping, and aggregation?\",\"answer\":\"Use SELECT with WHERE for filtering, and add GROUP BY for grouping. Aggregation functions like COUNT, AVG, MIN, MAX, and SUM operate within groups, optionally combined with HAVING and ORDER BY.\"},{\"question\":\"How can you change table structures or convert value types in MySQL?\",\"answer\":\"ALTER TABLE supports renaming tables and columns, adding or dropping columns, and modifying column data types. Use the CAST() function to convert a value to types such as CHAR, DATE, DECIMAL, SIGNED/UNSIGNED, TIME, YEAR, or JSON.\"}]","MySQL Cheat Sheet | PDF",1791929293]