Kolomnamen achterhalen (MySQL): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 8: Regel 8:
  
 
<pre>
 
<pre>
drop table if exists tmp
+
drop table if exists tmp;
 
create temporary table tmp select column_name  
 
create temporary table tmp select column_name  
  from information_schema.columns  
+
from information_schema.columns  
  where table_name="tabelnaam" and table_schema="databasenaam";
+
where table_name="tabelnaam" and table_schema="databasenaam";
 
</pre>
 
</pre>

Versie van 11 mei 2016 11:13

Kolomnamen achterhalen is simpel:

select column_name from information_schema.columns where table_name="tabelnaam" and table_schema="databasenaam";

Of wegschrijven in een tijdelijke tabel:

drop table if exists tmp;
create temporary table tmp select column_name 
from information_schema.columns 
where table_name="tabelnaam" and table_schema="databasenaam";