Dynamic SOQL refers to the creation of a SOQL string at runtime with Apex code. Dynamic SOQL enables you to create more flexible applications. For example, you can create a search based on input from an end user, or update records with varying field names.
The database query method can be used wherever an inline SOQL query can be used, such as in regular assignment statements and for loops. The results are processed in much the same way as static SOQL queries are processed.
You can use simple bind variables in dynamic SOQL query strings. The following is allowed:
String myTestString = 'Account';
List<sObject> sobjList = Database.query('SELECT Id FROM' + myTestString);
Reference document: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm