Blogger Information
Blog 41
fans 2
comment 0
visits 29708
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
mysql数据库ddl与dml语言实操
月光下,遗忘黑暗
Original
555 people have browsed it

演示效果

  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>
Correcting teacher:灭绝师太灭绝师太

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post