MariaDB data opvragen

Docent uitwerking

Geschreven door Peter van Gemert

Op 20 augustus 2023


Simpele queries

  databaseserver $ mysql -udeltion -p
  
  databaseserver mariadb> USE datacenter;
  databaseserver mariadb> DESCRIBE servers;
  
  databaseserver mariadb> SELECT * FROM servers;
  databaseserver mariadb> SELECT servernaam,ipbeheer FROM servers;
  databaseserver mariadb> SELECT servernaam,ipbeheer FROM servers ORDER BY servernaam;
  databaseserver mariadb> SELECT * FROM servers WHERE servernaam = "fd2-ubuntu-webserver";
  databaseserver mariadb> SELECT * FROM servers WHERE servernaam = "fd2-ubuntu-webserver" ORDER BY ipbeheer;
  databaseserver mariadb> SELECT servernaam FROM servers WHERE ipbeheer = "10.10.0.13";

Join queries

  databaseserver mariadb> DESCRIBE oses;
  databaseserver mariadb> SELECT * from servers
      -> JOIN oses ON servers.osid = oses.osid;
  
  databaseserver mariadb> SELECT servernaam,osnaam from servers
      -> JOIN oses ON servers.osid = oses.osid
      -> ORDER BY oses.osnaam;