本文主要是介绍mysql使用06,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
mysql> use test;Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> #现在 我们来看一下 整型的数据
mysql> #tinyint 1字节 -128-127 或者 0-255
mysql> #smallint 2字节 -32768----32767 或者 0----65535
mysql> #mediumint 3字节 -8488608---8388607 或者 0---16777215
mysql> #int 4字节
mysql> #bigint 8字节
mysql>
mysql> create table ttt(a int(4) zerofill);
ERROR 1050 (42S01): Table 'ttt' already exists
mysql> drop table ttt;
Query OK, 0 rows affected (0.03 sec)
mysql> create table ttt(a int(4) zerofill);
Query OK, 0 rows affected (0.10 sec)
mysql> desc ttt;
+-------+--------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------------------+------+-----+---------+-------+
| a | int(4) unsigned zerofill | YES | | NULL | |
+-------+--------------------------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> #我们可以看到一个现象 在加了zerofill的属性后 自动设为unsigned
mysql> #mysql数据库支持两种浮点类型 单精度的float类型以及双精度的double precision类型
mysql> #高精度的类型有decimal 和 numeric
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| Nums |
| a |
| employees |
| new_emp |
| sales |
| sessions |
| t |
| test01 |
| timetest |
| ttt |
| updatetime |
| yeartest |
| z |
+----------------+
13 rows in set (0.00 sec)
mysql> drop table t;
Query OK, 0 rows affected (0.04 sec)
mysql> drop table ttt;
Query OK, 0 rows affected (0.04 sec)
mysql> create table t (a decimal);
Query OK, 0 rows affected (0.11 sec)
mysql> desc table;
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 'table' at line 1
mysql> desc t;
+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| a | decimal(10,0) | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> create table Nums(
-> a int unsigned not null primary key
-> )engine=innodb;
ERROR 1050 (42S01): Table 'Nums' already exists
mysql>
mysql> delimiter //
mysql> create procedure pCreateNum(cnt int unsigned)
-> begin
-> declare s int unsigned default 1;
-> truncate table Nums;
-> while s<= cnt do
-> begin
-> insert into Nums select s;
-> set s=s+1;
-> end;
-> end while;
-> end;
-> //
ERROR 1304 (42000): PROCEDURE pCreateNum already exists
mysql> delimiter //
mysql> create procedure pCreateNums(cnt int unsigned)
-> begin
-> declare s int unsigned default 1;
-> truncate table Nums;
-> while s<= cnt do
-> begin
-> insert into Nums select s;
-> set s=s+1;
-> end;
-> end while;
-> end;
-> //
Query OK, 0 rows affected (0.00 sec)
mysql> #ok
mysql> #现在我们建立了一个过程函数
mysql> #记得建立的方式 delimiter // 最后//结束
mysql>
mysql> call pCreateNums(1000);
->
-> Ctrl-C -- exit!
Aborted
# the last it has some error
这篇关于mysql使用06的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!