Data table operations
Data table operations

mysql> create table emp( ename varchar(10), hiredate date, sal float(10,2), deptno int(2) ); Query OK, 0 rows affected (0.63 sec) mysql> create table dept( deptno int(4), deptname varchar(20)); Query OK, 0 rows affected (0.12 sec)
View table field structure information

mysql> desc emp; +----------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+---------------+------+-----+---------+-------+ | ename | varchar(10) | YES | | NULL | | | hiredate | date | YES | | NULL | | | sal | decimal(10,2) | YES | | NULL | | | deptno | int(2) | YES | | NULL | | +----------+---------------+------+-----+---------+-------+ 4 rows in set (0.39 sec)View table creation SQL statement
View table creation statement
Category detailed explanation Basic Syntax show create table table name\G;
Example show create table emp \G;
Example description View the creation statement of table emp
Execute the complete example:
mysql> show create table emp \G Table: emp Create Table: CREATE TABLE emp ( ename varchar(10) DEFAULT NULL, hiredate date DEFAULT NULL, sal decimal(10,2) DEFAULT NULL, deptno int(2) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 1 row in set (0.00 sec)The above table In the create SQL statement, in addition to the table definition, you can also see the table's engine (storage engine) and charset (character set) and other information. The meaning of the "\G" option is to enable records to be arranged vertically according to fields, making it easier to display records with relatively long content. \G cannot be followed by a semicolon;, because \G is functionally equivalent to;, if a semicolon is added, it will be;; (2 semicolons), SQL syntax error
ERROR: No query specified
Delete table
##
mysql>drop table emp: Query ok,0 rows affected(0.34 sec)
Note: Delete table. Both tables and data will be lost. Please do not back up data before deleting important tables. Specify the table engine and character set
At the end of creating the table, we often use the MyISAM or InnoDB engine. When specifying the engine, we can use:
ENGINE=InnoDB
Specify the table default character set:
DEFAULT CHARSET=utf8
The effect is as follows:
CREATE TABLE emp ( useraname varchar(10) DEFAULT NULL, password date DEFAULT NULL, )ENGINE=InnoDB DEFAULT CHARSET=utf8;
new file
<?php
echo "Hello Mysql";
?>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















