什么是sql文件?
來源:程序員人生 發布時間:2014-06-16 21:45:43 閱讀次數:6946次
什么是sql文件?
在回答這個問題前先用記事本打開這種文件,發現一條條的sql語句,這就和dos中的bat批處理文件很相似,把若干命令集成到一個文件中,這樣省去了重復輸入的繁瑣。sql文件sql語句批處理文件。
如何執行它呢?(僅限于在mysql中)
建立hi.sql文件:
create table hi(name char(10),id char(4));
用root用戶登陸數據庫:
E:\mysql\bin>mysql -u root -p123
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 26
- Server version: 5.0.37-community-nt MySQL Community Edition (GPL)
- Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
更改數據庫:
mysql> use mysql;
運行該腳本文件:
mysql> source hi.sql
- Query OK, 0 rows affected (0.08 sec)
查看hi表的結構:
mysql> desc hi;
- +-------+----------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-------+----------+------+-----+---------+-------+
- | name | char(10) | YES | | NULL | |
- | id | char(4) | YES | | NULL | |
- +-------+----------+------+-----+---------+-------+
- 2 rows in set (0.02 sec)
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
------分隔線----------------------------
------分隔線----------------------------