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
Asked
Active
Viewed 1,647 times
1
-
Sqlite doesn't have a `SHOW` statement. See https://www.sqlite.org/lang.html for what it understands. – Shawn Dec 11 '18 at 17:11
1 Answers
0
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

szmate1618
- 1,545
- 1
- 17
- 21