Sqlserver // Tables

Asked

Viewed 37 times

0

I created a Database and it contains two tables, I put the script:

Table Client

Create table Cliente( 
    Cod_Cliente int Primary key 
    NOME Varchar(50)
    SOBRENOME Varchar (50)
) 
GO 

Table Size of the Company

Create table Porte_Empresa( 
   PEQUENO float 
   MÉDIO float 
   GRANDE float
)
GO 

BD: Create Database CADASTRO

The point is I’m not seeing the tables on the left side when I do the BD expansion even giving refresh.

  • You can use Select tables? Post the script you used!

  • Put the Scrip you used to try to create the database and table.

  • Unfortunately not. I created two tables:Customer and Company Size. Client table script: Create table Client( Cod_client int Primary key NAME Varchar(50) LAST NAME Varchar (50) ) GO Enterprise Size Table Create table Porte_company( SMALL float MEDIUM FLOAT LARGE float ) GO BD: Create Database REGISTER

1 answer

2


If you used this order when executing the query, probably your tables should be in DATABASE master. If you run a query without setting a DB, by default it will adopt the DATABASE commands called master.

It is necessary to use the USE nomedadb, see in the image below: inserir a descrição da imagem aqui

Follows Code:

CREATE DATABASE Cadastro
GO

USE Cadastro

Create table Cliente( 
    Cod_Cliente int Primary key IDENTITY,
    NOME Varchar(50),
    SOBRENOME Varchar (50)
) 
GO 

Create table Porte_Empresa( 
   PEQUENO float, 
   MÉDIO float,
   GRANDE float
)
GO 

I hope I’ve helped!!!

  • Excellent, Paul.Thank you!! I excluded the bank (REGISTER) and the tables and created again using the 'USE'. I didn’t know about this command, every time it is necessary to create a DB the 'USE''?

  • Every time you run a query, you have to set a database to receive "such a query". To arrow it the keyword is the USE. Let’s assume that after creating your tables, you create a new Database without closing the query, the tables you create below will be stored inside the previous one, if you do not use USE.

  • Understood, very grateful for the explanation.

  • Vlw, tamos aê!!! Don’t forget to mark the answer as useful if you have served.

  • 1

    @Ericrosario, if solved the problem, marks the answer as accepted ;)

  • Done. Thank you, guys!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.