+ 1
Sql create table
Create Table accountancy.employee ( // something ); Before that theres no definition about any accountancy table which I at first thought would be like theres an accountancy table and we derive another table from that, that is called employee. I dont know anything about sql its just the class i need to study for now. Is accountancy.employee just variable name? Does dot between them mean anything? Are we allowed to have table names with dot instead of underscore?
2 odpowiedzi
+ 4
A table name may be preceded by database name where the respective table belongs. Where specified, the database name and table name are separated by a dot.
Table name may contain underscore, but a dot in table name is discouraged. Logically this makes sense cause the dot has a different function in SQL, one of which was being a separator of database and table name (also table and column name in queries).
+ 3
Before you create a table, you create a database. You then create tables inside a database.
If you don't know the name of databases that exists then you can use the below.
show databases;
It will list all databases.
use database_name;
This will select the database.
Then you can do-
create table employee(
// Statements
);
If you know the database name already then you can do like below.
create table database_name.table_name(
// Statements
);