1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| # 第八课时数据测试
DESC tbl_name; DESCRIBE tbl_name; SHOW COLUMNS FROM tbl_name;
SHOW CREATE TABLE tbl_name;
CREATE TABLE test1( num1 TINYINT, num2 SMALLINT, num3 MEDIUMINT, NUM4 INT, NUM5 BIGINT );
INSERT test1 VALUES(-128,-32768,0,-2147483648,0);
SELECT *FROM test1;
CREATE TABLE test3( num1 TINYINT ZEROFILL, num2 SMALLINT ZEROFILL, num3 MEDIUMINT ZEROFILL, num4 INT ZEROFILL, num5 BIGINT ZEROFILL ); INSERT test3 values(1,1,1,1,1);
CREATE TABLE test4( num1 FLOAT(6,2), num2 DOUBLE(6,2), num3 DECIMAL(6,2) ); INSERT test4 VALUES(3.1415,3.1415,3.1415); SELECT * FROM test4; SELECT * FROM test4 WHERE num2 = 3.14;
#第九课时测试字符串
CREATE TABLE IF NOT EXISTS test5( str1 CHAR(5), str2 VARCHAR(5) ); INSERT test5 VALUES('1','1'); INSERT test5 VALUES('12345','12345'); INSERT test5 VALUES('123456','123456');
SELECT CONCAT('-',str1),CONCAT('-',str2) FROM test5; SELECT LENGTH('A')
#第十课时测试枚举类型 CREATE TABLE IF NOT EXISTS test7( sex ENUM('nan','nv','baomi') ); INSERT test7 VALUES('nan') INSERT test7 VALUES('nv') INSERT test7 VALUES('baomi')
CREATE TABLE IF NOT EXISTS test8( fav SET('A','B','C','D') ); INSERT test8 VALUES('A,C,D'); INSERT test8 VALUES('A,D,E'); INSERT test8 VALUES(15); SELECT * FROM test8;
#第十课时测试日期时间类型
CREATE TABLE IF NOT EXISTS test9( birth YEAR ); INSERT test9 VALUES(1901); INSERT test9 values('2000'); INSERT test9 VALUES(0); INSERT test9 VALUES('0'); SELECT * FROM test9;
|