// connect to the database $db = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password'); // create a new table $tableName = 'users'; $db->exec(" CREATE TABLE $tableName ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id) ); ");
use Illuminate\Support\Facades\Schema; // create a new table $tableName = 'users'; Schema::create($tableName, function ($table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->timestamps(); });This example also creates a new table called "users" with three columns: "id", "name", and "email". The "id" column is defined as an auto-incrementing integer with the "increments" method. The "name" and "email" columns are defined as strings with a maximum length of 255 characters. The "email" column is also set as a unique index. The "timestamps" method adds "created_at" and "updated_at" columns to the table to track when records are created and updated.