mysql增查刪改
mysql> use test Database changed mysql> create table class ( -> id int primary key auto_increment, -> sname varchar(10) not null default ``, -> gender char(1) not null default ``, -> company varchar(20) not null default ``, -> salary decimal(6,2) not null default 0.00, -> fanbu smallint not null default 0 -> )engine myisam charset utf8; Query OK, 0 rows affected (0.11 sec) mysql> desc class; +---------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | sname | varchar(10) | NO | | | | | gender | char(1) | NO | | | | | company | varchar(20) | NO | | | | | salary | decimal(6,2) | NO | | 0.00 | | | fanbu | smallint(6) | NO | | 0 | | +---------+--------------+------+-----+---------+----------------+ 6 rows in set (0.02 sec) mysql> insert into class -> (id,sname,gender,company,salary,fanbu) -> values -> (1,`張三`,`男`,`百度`,8889.23,250); Query OK, 1 row affected (0.05 sec) mysql> insert into class -> (sname,gender,salary) -> values -> (`科比`,`男`,9000); Query OK, 1 row affected (0.00 sec) mysql> select * from class; +----+--------+--------+---------+---------+-------+ | id | sname | gender | company | salary | fanbu | +----+--------+--------+---------+---------+-------+ | 1 | 張三 | 男 | 百度 | 8889.23 | 250 | | 2 | 科比 | 男 | | 9000.00 | 0 | +----+--------+--------+---------+---------+-------+ 2 rows in set (0.00 sec) mysql> insert into class -> values -> (3,`李四`,`女`,`新浪`,5888.90,125); Query OK, 1 row affected (0.00 sec) mysql> insert into class -> values -> ; 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 `` at line 2 mysql> insert into class -> (sname,company,salary) -> values -> (`劉備`,`皇室`,1000.00), -> (`孫策`,`江東集團`,8000.00), -> (`曹操`,`魏國`,5000.00); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from class; +----+--------+--------+--------------+---------+-------+ | id | sname | gender | company | salary | fanbu | +----+--------+--------+--------------+---------+-------+ | 1 | 張三 | 男 | 百度 | 8889.23 | 250 | | 2 | 科比 | 男 | | 9000.00 | 0 | | 3 | 李四 | 女 | 新浪 | 5888.90 | 125 | | 4 | 劉備 | | 皇室 | 1000.00 | 0 | | 5 | 孫策 | | 江東集團 | 8000.00 | 0 | | 6 | 曹操 | | 魏國 | 5000.00 | 0 | +----+--------+--------+--------------+---------+-------+ 6 rows in set (0.00 sec) mysql> update class set gender=`男` where id=4; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from class; +----+--------+--------+--------------+---------+-------+ | id | sname | gender | company | salary | fanbu | +----+--------+--------+--------------+---------+-------+ | 1 | 張三 | 男 | 百度 | 8889.23 | 250 | | 2 | 科比 | 男 | | 9000.00 | 0 | | 3 | 李四 | 女 | 新浪 | 5888.90 | 125 | | 4 | 劉備 | 男 | 皇室 | 1000.00 | 0 | | 5 | 孫策 | | 江東集團 | 8000.00 | 0 | | 6 | 曹操 | | 魏國 | 5000.00 | 0 | +----+--------+--------+--------------+---------+-------+ 6 rows in set (0.00 sec) mysql> select * from classG *************************** 1. row *************************** id: 1 sname: 張三 gender: 男 company: 百度 salary: 8889.23 fanbu: 250 *************************** 2. row *************************** id: 2 sname: 科比 gender: 男 company: salary: 9000.00 fanbu: 0 *************************** 3. row *************************** id: 3 sname: 李四 gender: 女 company: 新浪 salary: 5888.90 fanbu: 125 *************************** 4. row *************************** id: 4 sname: 劉備 gender: 男 company: 皇室 salary: 1000.00 fanbu: 0 *************************** 5. row *************************** id: 5 sname: 孫策 gender: company: 江東集團 salary: 8000.00 fanbu: 0 *************************** 6. row *************************** id: 6 sname: 曹操 gender: company: 魏國 salary: 5000.00 fanbu: 0 6 rows in set (0.00 sec)
#建立檔案,並把操作mysql表的內容全部顯示 tee F:1230.sql #學生表 create table class ( id int primary key auto_increment, sname varchar(10) not null default ``, gender char(1) not null default ``, company varchar(20) not null default ``, salary decimal(6,2) not null default 0.00, fanbu smallint not null default 0 )engine myisam charset utf8; #檢視錶的結構 desc class; #增加一條資訊 insert into class (id,sname,gender,company,salary,fanbu) values (1,`張三`,`男`,`百度`,8889.23,250); #特殊情況 insert into class (sname,gender,salary) values (`科比`,`男`,9000); #插入所有列 insert into class values (3,`李四`,`女`,`新浪`,5888.90,125); #插入多列 insert into class (sname,company,salary) values (`劉備`,`皇室`,1000.00), (`孫策`,`江東集團`,8000.00), (`曹操`,`魏國`,5000.00); #修改 update class set gender=`男` where id=4; #全部改 update class set fanbu=100 where 1; #where 1 ,1 表示真,1恆為真 #刪除 delete from class where id=1; #查詢 select * from class;
相關文章
- mysql增刪改查MySql
- mysql基本增刪改查MySql
- mysql資料增刪改查操作MySql
- MySQL基礎操作(增刪改查)MySql
- 增刪改查
- MySQL表的增刪查改(提高篇)MySql
- MySQL表的增刪改查(基礎)MySql
- MySql 表資料的增、刪、改、查MySql
- MySQL的基本語法(增,刪,改,查)MySql
- indexedDB 增刪改查Index
- SQL增刪改查SQL
- Mongoose查增改刪Go
- FMDB增刪改查
- PHP MySQL (一)程式導向 增刪查改PHPMySql
- Go實現對MySQL的增刪改查GoMySql
- linux-MySQL基本指令-增刪改查LinuxMySql
- MySQL表的增刪改查(進階)下MySql
- 手擼Mysql原生語句--增刪改查MySql
- mysql 資料增刪改查基本語句MySql
- layui的增刪改查UI
- sql指令,增,刪,查,改SQL
- EFCore之增刪改查
- 列表的增刪改查
- 字典的增刪改查
- redist的增刪改查Redis
- Mybatis的增刪改查MyBatis
- MongoDB增刪改查操作MongoDB
- MongoDB的增刪改查MongoDB
- ThinkPHP的增、刪、改、查PHP
- mongodb 基本增刪改查MongoDB
- Node.js+Express+Mysql 實現增刪改查Node.jsExpressMySql
- MySQL增刪改查學習筆記(手寫)MySql筆記
- MySQL資料庫 ---MySQL表的增刪改查(進階)MySql資料庫
- koa+mysql實現增刪改查-全棧之路MySql全棧
- MySQL 常用命令手冊 增刪改查大法MySql
- Golang原生sql操作Mysql資料庫增刪改查GolangMySql資料庫
- Node連線MySQL並封裝其增刪查改MySql封裝
- 資料庫的簡介和MySQL增刪改查資料庫MySql