Content about Java ERP Solution for Reviews Best ERP Software for sale and Free Software with Java OpenSource for Free Download
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

SQL queries create table example sql command to create table

We can Create table with SQL command for example code below

CREATE TABLE table_name(
  column_name1 data_type(size),
  column_name2 data_type(size),
  column_name3 data_type(size));

Example SQL code for create table

CREATE TABLE Student(
   student_id int,
   student_name varchar(255));

Note: with difference DBMS  the command will not the same for example mysql  have datatype varchar but in Oracle use data type Vaarchar2

Mysql query for creating table example sql code for create new table with select command

We can create table with select command from another table with example sql command below

Example sql command for mysql query for creating table

CREATE TABLE new_std_table
  SELECT * from std_table

you can select with specify field name or using where condition , group by , order by for example below

CREATE TABLE new_std_table
  SELECT std_id,std_name from std_table where std_name like '%anna%' order by std_id

 Note: this command will support  MySql DBMS in other DBMS may be some difference

Mysql create table int with unsigned int column example sql command

Mysql create table int with unsigned int column example sql command to caeate table with
mysql create unsigned int column and mysql create table unsigned int primary key  in below

Mysql create unsigned int column
using key word UNSIGNED after datatype of field for example

CREATE TABLE test_table (
   test_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
   test_desc TEXT
);

Mysql create table unsigned int primary key

CREATE TABLE test_table (
   test_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
   test_desc TEXT
   PRIMARY KEY ('test_id')
);

Note: using keyword UNSIGNED to tell the data type is UNSIGNED  and using keyword PRIMARY KEY (fieldname) to tell this field is primary key