Laraadmin and sqlite “SHOW”: syntax error (SQL: SHOW TABLES)

柔情痞子 提交于 2021-02-10 19:38:15

问题


I have installed laraadmin as for quick admin with using sqlite. But problem is when i am going to create something getting SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error (SQL: SHOW TABLES) Thanks


回答1:


Unfortunately SQLite doesn't know SHOW TABLES, but instead it has:

special command line commands, like .schema or .tables (with optional LIKE patterns)

a master metadata table, called sqlite_master

So let's say you have the following tables:

sqlite> CREATE TABLE A(a INT, b, INT, c TEXT);
sqlite> CREATE TABLE B(a INT);
sqlite> CREATE TABLE AB(a TEXT, b TEXT);

You can query the schema:

sqlite> .schema
CREATE TABLE A(a INT, b, INT, c TEXT);
CREATE TABLE B(a INT);
CREATE TABLE AB(a TEXT, b TEXT);

Query the table names:

sqlite> .tables
A   AB  B

Query all the metadata:

sqlite> SELECT * FROM sqlite_master WHERE type = 'table';
table|A|A|2|CREATE TABLE A(a INT, b, INT, c TEXT)
table|B|B|3|CREATE TABLE B(a INT)
table|AB|AB|4|CREATE TABLE AB(a TEXT, b TEXT)

Query the schema of table names matching a specific LIKE pattern:

sqlite> .schema A%
CREATE TABLE A(a INT, b, INT, c TEXT);
CREATE TABLE AB(a TEXT, b TEXT);

Query the table names matching a specific LIKE pattern:

sqlite> .tables A%
A   AB


来源:https://stackoverflow.com/questions/53724862/laraadmin-and-sqlite-show-syntax-error-sql-show-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!