博客列表 >mysql数据库ddl与dml语言实操

mysql数据库ddl与dml语言实操

月光下,遗忘黑暗
月光下,遗忘黑暗原创
2021年05月16日 11:27:33554浏览

演示效果

  1. mysql> show databases;
  2. +--------------------+
  3. | Database |
  4. +--------------------+
  5. | information_schema |
  6. | mysql |
  7. | performance_schema |
  8. | qidian |
  9. | sys |
  10. | video |
  11. +--------------------+
  12. 6 rows in set (0.02 sec)
  13. mysql> mysql -v;
  14. 1064 - 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 'mysql -v' at line 1
  15. mysql> desc video
  16. -> ;
  17. 1146 - Table 'qidian.video' doesn't exist
  18. mysql> desc video;
  19. 1146 - Table 'qidian.video' doesn't exist
  20. mysql> use video
  21. -> ;
  22. Database changed
  23. mysql> show tables;
  24. +-----------------+
  25. | Tables_in_video |
  26. +-----------------+
  27. | admins |
  28. +-----------------+
  29. 1 row in set (0.02 sec)
  30. mysql> desc admins;
  31. +----------+-------------+------+-----+---------+----------------+
  32. | Field | Type | Null | Key | Default | Extra |
  33. +----------+-------------+------+-----+---------+----------------+
  34. | id | int(10) | NO | PRI | NULL | auto_increment |
  35. | username | varchar(20) | NO | | NULL | |
  36. | password | varchar(32) | NO | | NULL | |
  37. | truename | varchar(20) | NO | | NULL | |
  38. | gid | int(10) | NO | | NULL | |
  39. | status | tinyint(1) | NO | | 0 | |
  40. | add_time | int(10) | NO | | NULL | |
  41. +----------+-------------+------+-----+---------+----------------+
  42. 7 rows in set (0.03 sec)
  43. mysql> CREATE TABLE IF NOT EXISTS `runoob_tbl`(
  44. `runoob_id` INT UNSIGNED AUTO_INCREMENT,
  45. `runoob_title` VARCHAR(100) NOT NULL,
  46. `runoob_author` VARCHAR(40) NOT NULL,
  47. `submission_date` DATE,
  48. PRIMARY KEY ( `runoob_id` )
  49. )ENGINE=InnoDB DEFAULT CHARSET=utf8;
  50. Query OK, 0 rows affected (0.03 sec)
  51. mysql> desc runoob_tbl
  52. -> ;
  53. +-----------------+------------------+------+-----+---------+----------------+
  54. | Field | Type | Null | Key | Default | Extra |
  55. +-----------------+------------------+------+-----+---------+----------------+
  56. | runoob_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
  57. | runoob_title | varchar(100) | NO | | NULL | |
  58. | runoob_author | varchar(40) | NO | | NULL | |
  59. | submission_date | date | YES | | NULL | |
  60. +-----------------+------------------+------+-----+---------+----------------+
  61. 4 rows in set (0.03 sec)
  62. mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as',432432);
  63. 1292 - Incorrect date value: '432432' for column 'submission_date' at row 1
  64. mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as','432432');
  65. 1292 - Incorrect date value: '432432' for column 'submission_date' at row 1
  66. mysql> insert into runoob_tbl(runoob_title,runoob_author,submission_date) value('a','as','2002/1/1');
  67. Query OK, 1 row affected (0.00 sec)
  68. mysql> select *from runoob_tbl;
  69. +-----------+--------------+---------------+-----------------+
  70. | runoob_id | runoob_title | runoob_author | submission_date |
  71. +-----------+--------------+---------------+-----------------+
  72. | 1 | a | as | 2002-01-01 |
  73. +-----------+--------------+---------------+-----------------+
  74. 1 row in set (0.03 sec)
  75. mysql>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议