RMySQL学习笔记——RMySQL基本操作

来源:互联网 发布:旅游细分市场 知乎 编辑:程序博客网 时间:2024/06/05 08:15

RMySQL基本操作:

下面列出 RMySQL 的基本操作,基本上都会列出相应的SQL语句:

注意以 “mysql> ” 开头的就是对应的SQL语句

1、连接数据库

> con <- dbConnect(MySQL(), user="root", password="", dbname="test", host="localhost.localdomain")//相当与SQL[root@localhost pubuser1]# mysql -u root -pEnter password: mysql> use testReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed

2、查看数据库基本信息

查看所有的表:> dbListTables(con) [1] "t_user"mysql> show tables;+----------------+| Tables_in_test |+----------------+| t_user         |+----------------+1 row in set (0.00 sec)查询表中的所有字段:> dbListFields(con, "t_user")[1] "id"   "user"mysql> select column_name from information_schema.columns where table_schema='test';+-------------+| column_name |+-------------+| id          || user        |+-------------+


待续。。。。。。


0 0